I have an Image type column in MSSQL database named photo. The name of database is also photo (I know thats bad).
I want to get this image and store it back in some other record.
Here is my code:
b.com.CommandText = "SELECT photo from photo WHERE model=@model";
b.com.Parameters.Add("@model", txt_model.Text.Trim());
if (b.con.State == ConnectionState.Closed)
b.con.Open();
b.dr = b.com.ExecuteReader();
if (b.dr.HasRows)
{
b.dr.Read();
b.com.Parameters.Add("@j", b.dr.GetValue(0));
b.dr.Close();
}
Here is my exception thrown by ExecuteScalar() when I tried to insert this image again.
Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.
What I have tried:
Here is my code:
b.com.CommandText = "SELECT photo from photo WHERE model=@model";
b.com.Parameters.Add("@model", txt_model.Text.Trim());
if (b.con.State == ConnectionState.Closed)
b.con.Open();
b.dr = b.com.ExecuteReader();
if (b.dr.HasRows)
{
b.dr.Read();
b.com.Parameters.Add("@j", b.dr.GetValue(0));
b.dr.Close();
}
Here is my exception thrown by ExecuteScalar() when I tried to insert this image again.
Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.