Thank you Qazi. I have tried it. This is the command:
using ( objSqlCMD = new SqlCommand(" INSERT INTO Table(Field1, Field2, " +
" Field3, Field4" +
" VALUES ('" + tmp_strNameFDC + "', '" + tmp_byteFileNameBytes + "', '" + strCode + "', 'Yes')", objSqlCONN))
{
objSqlCMD.Parameters.Add("'" + tmp_byteFileNameBytes + "'", SqlDbType.VarBinary, tmp_intFileSize).Value = tmp_byteFileNameBytes;
objSqlCMD.ExecuteNonQuery();
}
I have tried it like this as well:
using ( objSqlCMD = new SqlCommand(" INSERT INTO
Table(Field1, Field2, " +
" Field3, Field4" +
" VALUES (@'" + tmp_strNameFDC + "',@ '" +
tmp_byteFileNameBytes + "', @'" + strCode + "', @'Yes')", objSqlCONN))
{
objSqlCMD.Parameters.Add("@'" +
tmp_byteFileNameBytes + "'", SqlDbType.VarBinary, tmp_intFileSize).Value
= tmp_byteFileNameBytes;
objSqlCMD.ExecuteNonQuery();
}
I get these errors.
An error occured: 'Incorrect syntax near 'System.Byte[]'.
Incorrect syntax near
the keyword 'VALUES'.
I have defined the byte vector like this:
byte[] byteFileNameBytes = new byte[209715200];
If I try it like this:
using ( objSqlCMD = new SqlCommand(" INSERT INTO
Table(Field1, Field2, " +
" Field3, Field4" +
" VALUES ('" + tmp_strNameFDC + "', @binaryValue, '" + strCode + "', 'Yes')", objSqlCONN))
{
// Replace 8000, below, with the correct size of the field
objSqlCMD.Parameters.Add("@binaryValue", SqlDbType.VarBinary, tmp_intFileSize).Value = tmp_byteFileNameBytes;
objSqlCMD.ExecuteNonQuery();
}
I get only this error:
Incorrect syntax near
the keyword 'VALUES'.
I do not know what could be wrong here. I need your help please. Thank you!