日期:2014-05-18 浏览次数:21049 次
UPDATE YX_TASK_ATTACH SET TASK_CD = 'EML', SCHEDULELDID = 'TASK257', IMG_EDM = 'System.Byte[]', ↑↑↑↑↑↑↑↑↑↑↑↑↑ ※IMG_EDM是image类型 UPDATE_DT = '2011-12-26 16:56:22' WHERE SCHEDULELDID = 'TASK257'
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 file=(@file),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();