C# mysql problem
-
hi all i want to save images to database. I use this code private int SaveToDB(string imgName, byte[] imgbin, string imgcontenttype) { //use the web.config to store the connection string MySqlConnection connection = new MySqlConnection(ConfigurationSettings.AppSettings["DSN"]); MySqlCommand command = new MySqlCommand( "INSERT INTO Image (img_name,img_data,img_contenttype) VALUES ( @img_name, @img_data,@img_contenttype )", connection ); MySqlParameter param0 = new MySqlParameter( "@img_name", MySqlDbType.VarChar,50 ); param0.Value = imgName; command.Parameters.Add( param0 ); MySqlParameter param1 = new MySqlParameter( "@img_data", MySqlDbType.LongBlob ); param1.Value = imgbin; command.Parameters.Add( param1 ); MySqlParameter param2 = new MySqlParameter( "@img_contenttype", MySqlDbType.VarChar,50 ); param2.Value = imgcontenttype; command.Parameters.Add( param2 ); connection.Open(); int numRowsAffected = command.ExecuteNonQuery(); connection.Close(); return numRowsAffected; } I have no errors it tells me that the image is save but when i go to my database there is only new row with no data. Where i am wrong P.S. I use MySql connector -- modified at 13:09 Friday 17th March, 2006