I have a client application built in C# which sends an image along with an id to a webservice. The webservice then receives these information and inserts them in a MySQL database. But someone, the webmethod cannot recognize the Image and instead, it is just saving @icon in the database….can anyone tell me where I am making an error? Thanks in advance!
[WebMethod]
public string sendDataToMySql(string application_id, byte[] buffer)
{
string MyConString = "SERVER=localhost;" +
"DATABASE=test;" +
"UID=root;" +
"PASSWORD=password;";
MySqlConnection connection = new MySqlConnection(MyConString);
connection.Open();
MySqlCommand command = new MySqlCommand("", connection);
command.CommandText = "UPDATE application SET icon='@icon' WHERE application_id='" + application_id +"';";
MySqlParameter oParam1 = command.Parameters.Add("@icon", MySqlDbType.Blob);
oParam1.Value = buffer;
command.ExecuteNonQuery();
connection.Close();
return "Data was inserted successfully!";
}
If i had to guess anything, it’d be that
SET icon='@icon'needs to beSET icon=@icon. The former only makes sense if you actually want to insert that string literal.And the second thing I’d be wondering about is
@iconvs.?icon. I’m seeing asp.net code on stackoverflow referencing the question mark syntax and dev.mysql.com referencing the at symbol syntax.I must confess which would be right for any existing drivers out there.