开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜