c# - Object must implement IConvertible When inserting bytes into VARBINARY field -
I have seen many people on the web with this problem, and I still have to find a solution that is of my problem Resolves
I have this code here:
byte [] bytes = btn boursefilebites; SqlConnection conn = New SqlConnection (Configuration Manager. Connection Strings ["shbndbConnectionString"]. ConnectionString); SqlCommand cmd = new SqlCommand ("tblProject (id, update, status update, attachment) value (@ project ID, GETDATE (), @ status update, @ file)", insert;); Cmd.Parameters.Add ("@file", SqlDbType.VarBinary). Value = bytes; Cmd.Parameters.Add ("@ statusUpdate", SqlDbType.NVarChar) .Value = txtStatusUpdate; Cmd.Parameters.Add ("@ projectId", SqlDbType.Int) .Value = lblProjectId.Text; //cmd.CommandType = CommandType.StoredProcedure; Conn.Open (); If (CMD.exequintonclline ()> = 1) {lblDone.Text = "success"; LblDone.Visible = true; } Conn.Close ();
Now I keep getting this error:
The object must implement IConvertabel.
What I understand is because I am attempting to insert an array in the table, but to go to every website I say that the way I put it, he is right.
Why did I get this error?
VARBINARY
column length
in my table The reason for the exception is most likely this line, where you are trying to specify the entire text box as a parameter value:
cmd.Parameters.Add ("@ statusUpdate", SqlDbType.NVarChar) .Value = txtStatusUpdate;
Use txtStatusUpdate.Text
to get the actual value from the text box.
cmd.Parameters.Add ("@statest update", SqlDbType.NVarChar) .Value = txtStatusUpdate.Text;
Comments
Post a Comment