Sir,
I am in a midst of an error while working on inserting image into database.
ASP.NET is the platform and SQL SERVER is the RDBMS.
My error is : -Failed to convert parameter value from a String to a Byte[].
Please go through the screenshot and reply with the correct code.
Please take a look to the table structure where I want to insert my data:-
my sql server query to insert data:-
And finally the c# code for insert function:-

Vincent Maverick DuranoPosted May 24, 2016, 8:16 AM
Bineesh ViswanathPosted May 25, 2016, 1:07 AM
HttpPostedFile postedFile = flUpldCoverPhoto.PostedFile;
postedFile.InputStream.Read(photo_aray, 0, length);
sqlCon.Open();
SqlCommand cmd = new SqlCommand("SaveBookDetails", sqlCon);
cmd.Parameters.Add("@asBookName", SqlDbType.VarChar).Value = txtBookName.Text;
cmd.Parameters.Add("@asBookPhoto", SqlDbType.Image).Value = photo_aray;
cmd.Parameters.Add("@asBookPrice", SqlDbType.Float).Value = txtBookPrice.Text.ToString();
cmd.Parameters.Add("@asAuthor", SqlDbType.VarChar).Value = txtBookAuthor.Text;
cmd.Parameters.Add("@asPublishedYear", SqlDbType.VarChar).Value = txtPublishYear.Text;
cmd.CommandType = CommandType.StoredProcedure;
int inCount = cmd.ExecuteNonQuery();
Bineesh ViswanathPosted May 24, 2016, 6:47 AM
Ravi PatelPosted May 24, 2016, 6:14 AM
Ranjit PowarPosted May 24, 2016, 5:59 AM