[RESOLVED][2005] MYSQL parameter problem
As the title says:
I got a problem using parameters in the mysql.data.client.mysqlcommand
This is my code:
Code:
Dim querystring As String
querystring = "INSERT INTO tblpicture(data) VALUES(@Picture)"
Dim QueryT As New MySqlCommand(querystring, connection)
QueryT.Parameters.Add("@Picture", MySqlDbType.String)
QueryT.Parameters(0).Value = "hello"
Console.WriteLine(QueryT.Parameters.Item(0).Value)
Console.WriteLine(QueryT.CommandText)
QueryT.ExecuteNonQuery() ' causes the error
error: #23000Column 'data' cannot be null
Data column i set was set to NOT NULL
I got truely no idea what is goeing wrong here.
I am planning on saving banairy data in the database and saw this as the only solution. It doesnt matter with what kind of datatype i try it, it wont work. So this was for people who wanted to ask why i dont just add the string in de string.
These are the 2 lines from the output.:
Code:
hello
INSERT INTO tblpicture(data) VALUES(@Picture)
So the parrams realy work as you see. I can read them out if i want to.
But the problem is that the value is not sended to the database.
Is there someone that can help me with it?
Greets
Re: [2005] MYSQL parameter problem
QueryT.prepare()
Use the prepare statement before executing the query. This should fix it.
Re: [2005] MYSQL parameter problem
I don't think MySQL supports "@" as a prefix for parameters does it? That's specifically for SQL server. I think MySQL uses ":" although I'm not 100% sure as I've never used MySQL. I'm sure there would be MySQL/ADO.NET examples on the Web that would tell you.
Re: [2005] MYSQL parameter problem
I have seen ?,@ and :. They use @ in one part of their documentation and ? in others - a little constancy might be helpful :)
http://dev.mysql.com/doc/refman/5.0/...parameter.html
Re: [2005] MYSQL parameter problem
ty ty people.
The problem was that i needed '?' instead of '@'
So thnx a lot. This one is solved.
Greets