开发者

Adding varchar parameter to MySQLCommand

开发者 https://www.devze.com 2023-03-29 15:38 出处:网络
I\'m trying to execute a MySQLCommand like so: Dim comCommand As MySqlCommand comCommand = New MySqlCommand(\"MyStoredProc\", conConnection)

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消