Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO.Net & MySQL: OleDbCommand object with partameters fails to execute

Status
Not open for further replies.

boolean

Programmer
Joined
Mar 5, 2002
Messages
35
Location
US
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.Parameters.Add("@AgencyId", 1)
OleDbCmd.CommandText = _SqlText
OleDbCmd.CommandType = CommandType.Text
' The connection opens just fine...
OleDbCmd.Connection.Open()
' This is what fails... command object with parameters fails...
objDatadrd = OleDbCmd.ExecuteReader(CommandBehavior.CloseConnection)
If objDatadrd.Read Then
MsgBox(objDatadrd("agency_code"))
End If

Thanks for the help...
Sham Sham aka boolean... be practical/be straight... true/false?!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top