请大侠指教,我如何用sql写,将二进制数组存入字段类型为Image的字段中,sqlserver2008环境
public static void updateState(long id, byte[] tel)
{
string strUpdate = "update T_Res set Tel=" +tel + ",Hobbies=5 where ID=" + id;
}
public static void updateState(long id, byte[] tel)
{
string strUpdate = "update T_Res set Tel=" +tel + ",Hobbies=5 where ID=" + id;
}
try
{
SqlParameter sp = new SqlParameter("@tel",tel,SqlDbType.Image);
SqlParameter sp1 = new SqlParameter("@id", tel, SqlDbType.BigInt);
mycon = GetCon();
mycon.Open();
mycom = new SqlCommand(strUpdate, mycon);
mycom.ExecuteNonQuery();
}我这样写对吗,
try
{
mycon = GetCon();
mycon.Open();
mycom = new SqlCommand(strUpdate, mycon);
mycom.Parameters.Add("@tel", tel, SqlDbType.Image);
mycom.Parameters.Add("@id", tel, SqlDbType.BigInt);
mycom.ExecuteNonQuery();
}
try
{
mycon = GetCon();
mycon.Open();
mycom = new SqlCommand(strUpdate, mycon);
mycom.Parameters.Add("@tel", SqlDbType.Image);
mycom.Parameters["@tel"] = tel;
mycom.Parameters.Add("@id", SqlDbType.BigInt);
mycom.Parameters["@id"] = id;??????id为long
mycom.ExecuteNonQuery();
}