0

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 )
myParam .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?

3
  • 1
    Try using MySqlDbType instead of SqlDbType? Commented Aug 22, 2011 at 13:06
  • Thanks. That was the problem. Commented Aug 22, 2011 at 13:51
  • i added it as an answer for the sake of completeness Commented Aug 22, 2011 at 13:54

2 Answers 2

2

Try using MySqlDbType instead of SqlDbType?

Sign up to request clarification or add additional context in comments.

Comments

1

Try to use without size

New MySqlParameter("?myParam", SqlDbType.VarChar)

1 Comment

This does seem to work. But I think Derek's solution is probably the right one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.