Adding varchar parameter to MySQLCommand
I'm trying to execute a MySQLCommand like so:
Dim comCommand As MySqlCommand
comCommand = New MySqlCommand("MyStoredProc", conConnection)
comCommand.CommandType = CommandType.StoredProcedure
myParam = New MySqlParameter("?myParam", SqlDbType.VarChar, 255) 'Error occurs here!
comCommand.Parameters.Add(myParam )
myPar开发者_运维技巧am .Value = "test"
comCommand.ExecuteNonQuery()
But I keep getting the following error when creating the "varchar" parameter:
"Invalid data type"
It seems to be something to do with the "size" parameter, but I don't see what is wrong with it. Can anyone help?
Try using MySqlDbType instead of SqlDbType?
Try to use without size
New MySqlParameter("?myParam", SqlDbType.VarChar)
精彩评论