I want to insert selected image from gridview into mysql table. When I try to, it gives me message saying"An exception of type 'System.InvalidCastException' occurred in App_Web_zptg3ta3.dll but was not handled in user code.Additional information: Unable to cast object of type 'System.Int32' to type 'System.Data.DataRow'."
Below is my code:if (gvImages.SelectedIndex != -1) { DataRow SelectedRowValue = ((DataRow)gvImages.SelectedValue); byte[] ImageBytes = (byte[])SelectedRowValue.ItemArray[1]; MySqlCommand cmd2 = new MySqlCommand("INSERT INTO rasmlar (Rasm) VALUES (@ImageSource)", con); cmd2.Parameters.Add("@ImageSource", MySqlDbType.Blob, ImageBytes.Length).Value = ImageBytes; cmd2.ExecuteNonQuery(); }
Attachment: Pupils.rar