110,539
社区成员
发帖
与我相关
我的任务
分享
OdbcConnection cn = new OdbcConnection("DSN=Testgdb;UID=SYSDBA;PWD=masterkey;");
try
{
//写入BLOB字段
byte[] myBlob = System.Text.Encoding.UTF8.GetBytes(TextBoxDetails.Text);
string myString = string.Format("update customer set SUMMARY= (@summary) where CUSTID='{0}' and SNAME='{1}'",TextBoxNo.Text , TextBoxCorp.Text);
cn.Open();
OdbcCommand cmd = new OdbcCommand(myString, cn);
cmd.Parameters.Add("@summary", SqlDbType.Image).Value = myData;
Response.Write(myString);
cmd.ExecuteNonQuery();
}
catch (OdbcException ex)
{ Response.Write(ex.Message); }
finally
{ cn.Close(); }
OdbcConnection cn = new OdbcConnection("DSN=Testgdb;UID=SYSDBA;PWD=masterkey;");
try
{
//写入BLOB字段
byte[] myBlob = System.Text.Encoding.UTF8.GetBytes(TextBoxDetails.Text);
string myString = "update customer set SUMMARY='"+ myBlob +"' where CUSTID='" + TextBoxNo.Text + "' and SNAME='" + TextBoxCorp.Text + "' ";
cn.Open();
OdbcCommand cmd = new OdbcCommand(myString, cn);
Response.Write(myString);
cmd.ExecuteNonQuery();
}
catch (OdbcException ex)
{ Response.Write(ex.Message); }
finally
{ cn.Close(); }
Image img = Image.FromFile(@"c:\test.jpg");
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] myData = ms.ToArray();
SqlConnection cn = new SqlConnection("Data Source=(local);Initial Catalog=utscadadb;Integrated Security=SSPI; User Id=sa;Password=ut2001;");
SqlCommand cmd = new SqlCommand("Update Table1 Set data = (@data) where id =3", cn);
cmd.Parameters.Add("@file ", SqlDbType.VarChar).Value = "d:\\test.jpg";
cmd.Parameters.Add("@data ", SqlDbType.Image).Value = myData;
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();