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 DuranoRank #238 · 10.3K reputationPosted May 24, 2016, 4:16 AM EDT
Ranjit PowarRank #553 · 4.4K reputationPosted May 24, 2016, 1:59 AM EDT
Ravi PatelRank #439 · 5.7K reputationPosted May 24, 2016, 2:14 AM EDT
Bineesh ViswanathRank #1,681 · 907 reputationPosted May 24, 2016, 2:47 AM EDT
Bineesh ViswanathRank #1,681 · 907 reputationPosted May 24, 2016, 9:07 PM EDT
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();