Unanswered: ADO.Net & MySQL: OleDbCommand object with partameters fails to execute
Yeah... have been trying to use ADO.NEt with MySQL and i havent really been very successful!
Heres what i do...
' Dimension them all....
Dim OleDbCmd As New OleDb.OleDbCommand()
Dim OleDbCnn As New OleDb.OleDbConnection()
Dim _SqlText, _ConnectionString As String
Dim objDatadrd As IDataReader
Dim _ReturnStatus As Integer
' The connection string...
_ConnectionString = "Provider=MySqlProv;Data Source=The source;Integrated Security=;Password=Thepassword;User ID=TheUID;Location=SERVER;Extended Properties="
OleDbCmd.Connection = OleDbCnn
OleDbCmd.Connection.ConnectionString = _ConnectionString
' The SQL STring...
_SqlText = "select * from agency where agency_id = ?"
' This string executes just fine because there arent any parameters...
' _SqlText = "select * from agency where agency_id = 1"
OleDbCmd.CommandText = _SqlText
OleDbCmd.CommandType = CommandType.Text
' The connection opens just fine...
' This is what fails... command object with parameters fails...
objDatadrd = OleDbCmd.ExecuteReader(CommandBehavior.CloseConnec tion)
If objDatadrd.Read Then
I had even tried downloading the native MySql Data provider from CoreLab! same problem... But this time around I get a
An unhandled exception of type 'CoreLab.MySql.MySqlException' occurred in corelab.mysql.dll
Additional information: You have an error in your SQL syntax near '?' at line 1