SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\cms.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("selecthome", con);
cmd.Parameters.Add("@monthlyachiever", SqlDbType.NVarChar).Value = monthlyachiever.Text;
cmd.Parameters.Add("@topachiever", SqlDbType.NVarChar).Value = txttopachiever.Text;
cmd.Parameters.Add("@training", SqlDbType.NVarChar).Value = txttraining.Text;
cmd.Parameters.Add("@otherinformation", SqlDbType.NVarChar).Value = txtotherinformationhome.Text;
cmd.Parameters.Add("@image", SqlDbType.Image).Value = Convert.ToByte( fileupload.FileContent);
cmd.CommandText = "selecthome";
string c1 = (string)cmd.Parameters["@monthlyachiever"].Value;
Label6.Text = c1;
string c2 = (string)cmd.Parameters["@topachiever"].Value;
Label4.Text = c2;
string c3 = (string)cmd.Parameters["@training"].Value;
Label2.Text = c3;
string c4 = (string)cmd.Parameters["@otherinformation"].Value;
Label3.Text = c4;
Image c5 = (Image)cmd.Parameters["@image"].Value;
Image1 = c5;
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
con.Close();
Asked
Active
Viewed 248 times
-1

Sudhakar Tillapudi
- 25,935
- 5
- 37
- 67
-
And on which line? Post the top of the stack-trace. – H H Feb 23 '14 at 10:23
1 Answers
1
The problem is this line: Convert.ToByte( fileupload.FileContent);
Since FileContent
is a Stream
you have to read the data from it, you cannot directly convert it to byte array.
See Creating a byte array from a stream on how to do that.