Problem with mysqlcommandbuilder
Posted: Sat 18 Mar 2006 22:38
Greetings:
I am using 3.20.9.0 version and MySql 5. and trying to use the insert sql command from the mysqlcommandbuilder.
This is the code generated by vb.net 2003
'mySqlInsertCommand1
'
Me.mySqlInsertCommand1.CommandText = "INSERT INTO state(state_id, state_descrioption) VALUES (:state_id, :state_descrioption)"
Me.mySqlInsertCommand1.Connection = Me.MySqlConnection1
Me.mySqlInsertCommand1.Name = "mySqlInsertCommand1"
Me.mySqlInsertCommand1.Parameters.Add(New CoreLab.MySql.MySqlParameter("state_id", CoreLab.MySql.MySqlType.VarChar, 2, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, ""))
Me.mySqlInsertCommand1.Parameters.Add(New CoreLab.MySql.MySqlParameter("state_descrioption", CoreLab.MySql.MySqlType.VarChar, 2, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, ""))
Me.mySqlInsertCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None
When I try to execute this command using the following lines:
mySqlInsertCommand1.Parameters.Add(":state_id", TextBox1.Text)
mySqlInsertCommand1.Parameters.Add(":state_descrioption", TextBox2.Text)
Try
MySqlConnection1.Open()
mySqlInsertCommand1.ExecuteNonQuery()
MySqlConnection1.Close()
Catch myerror As MySqlException
MsgBox("There was an error creating record: " & myerror.Message)
End Try
I get the following error:
An unhandled exception of type 'System.InvalidOperationException' occurred in corelab.mysql.dll
Additional information: ':state_id' parameter is missing at the statement
Can anyone advise what is wrong?
Thanks
I am using 3.20.9.0 version and MySql 5. and trying to use the insert sql command from the mysqlcommandbuilder.
This is the code generated by vb.net 2003
'mySqlInsertCommand1
'
Me.mySqlInsertCommand1.CommandText = "INSERT INTO state(state_id, state_descrioption) VALUES (:state_id, :state_descrioption)"
Me.mySqlInsertCommand1.Connection = Me.MySqlConnection1
Me.mySqlInsertCommand1.Name = "mySqlInsertCommand1"
Me.mySqlInsertCommand1.Parameters.Add(New CoreLab.MySql.MySqlParameter("state_id", CoreLab.MySql.MySqlType.VarChar, 2, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, ""))
Me.mySqlInsertCommand1.Parameters.Add(New CoreLab.MySql.MySqlParameter("state_descrioption", CoreLab.MySql.MySqlType.VarChar, 2, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, ""))
Me.mySqlInsertCommand1.UpdatedRowSource = System.Data.UpdateRowSource.None
When I try to execute this command using the following lines:
mySqlInsertCommand1.Parameters.Add(":state_id", TextBox1.Text)
mySqlInsertCommand1.Parameters.Add(":state_descrioption", TextBox2.Text)
Try
MySqlConnection1.Open()
mySqlInsertCommand1.ExecuteNonQuery()
MySqlConnection1.Close()
Catch myerror As MySqlException
MsgBox("There was an error creating record: " & myerror.Message)
End Try
I get the following error:
An unhandled exception of type 'System.InvalidOperationException' occurred in corelab.mysql.dll
Additional information: ':state_id' parameter is missing at the statement
Can anyone advise what is wrong?
Thanks