Paul Clement
6/6/2005 2:44:00 PM
On Sun, 5 Jun 2005 22:49:49 +0800, "Robert G" <no@nono.no> wrote:
¤ Hi, I''m using VB. NET 2003 and MySql. When I try to run the ExecuteNonQuery
¤ part, it keeps giving me this error.
¤
¤ My Code (simplified):
¤
¤ Dim cmdSql As OdbcCommand
¤ Dim Param As OdbcParameter
¤
¤ cmdSql = New OdbcCommand
¤ cmdSql = conn1.CreateCommand
¤
¤ cmdSql.CommandText = "INSERT INTO customer" & _
¤ " SET ic_no = @ic_no"
¤
¤ Param = New OdbcParameter("@ic_no", "123")
¤ cmdSql.Parameters.Add(Param)
¤
¤ Param.SourceVersion = DataRowVersion.Original
¤
¤ cmdSql.ExecuteNonQuery()
¤
¤ ---> Error: "Column IC_NO cannot be Null"
¤
¤ What''s wrong? I tried before without using the parameter by directly setting
¤ the value in the command, and with no problem. Please help me.
¤
Try using a question mark instead of the parameter name in your CommandText:
cmdSql.CommandText = "INSERT INTO customer" & _
" SET ic_no = ?"
You may also need to specify the Size of the parameter value since it is a string.
Paul
~~~~
Microsoft MVP (Visual Basic)