如题。
直接写SQL语句没问题:
tring kkk = "update lpxx set 图片=@BLOBData where ID='" + this.lpidbubian.Text.Trim() + "'";
SqlCommand cmd = new SqlCommand(kkk, conn);
//Create parameter for insert command and add to SqlCommand object.
SqlParameter prm = new SqlParameter("@BLOBData", SqlDbType.VarBinary, bytBLOBData.Length, ParameterDirection.Input, false,0, 0, null, DataRowVersion.Current, bytBLOBData);
cmd.Parameters.Add(prm);
conn.Open();
cmd.ExecuteNonQuery();
但是用SqlCommandBuilder方式下:
string str="select * from lpxx";
da = new SqlDataAdapter(str, conn);
ds = new DataSet();
da.Fill(ds, "lpxx");
dt = ds.Tables["lpxx"];
myBind = this.BindingContext[ds, "lpxx"];
SqlCommandBuilder cb = new SqlCommandBuilder(da);
修改命令:
try
{
int j= myBind.Position ;
DataRow dr = dt.Rows[j];
dr["名称"] = this.lpmc.Text;
dr["图片"]=("@BLOBData;//如何加入参数啊?
//SqlParameter prm = new SqlParameter("@BLOBData", qlDbType.VarBinary, bytBLOBData.Length, //ParameterDirection.Input, false,0, 0, null, DataRowVersion.Current, bytBLOBData);
// cmd.Parameters.Add(prm);
da.Update(ds,"lpxx");
ds.Tables["lpxx"].AcceptChanges();
[此贴子已经被作者于2006-12-2 9:37:34编辑过]