以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求助,关于二进制列 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102977) |
||||
-- 作者:晕了快扶我 -- 发布时间:2017/6/28 16:23:00 -- 求助,关于二进制列
代码发不出来,用附件 问题出错在用SQLCOMMAND出来的表,用SQLINSERTFILE的方式更新不了二进制列,估计是提到前台表的原因 那么用UPDATE的方式更新要如何做呢? [此贴子已经被作者于2017/6/28 16:26:36编辑过]
|
||||
-- 作者:晕了快扶我 -- 发布时间:2017/6/28 16:27:00 -- 顶 |
||||
-- 作者:晕了快扶我 -- 发布时间:2017/6/28 16:29:00 -- Dim dr As DataRow = Tables("职员信息管理_职员信息表").Current.DataRow If dr IsNot Nothing Dim dlg As New OpenFileDialog dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png" If dlg.ShowDialog = DialogResult.OK Then dr.SQLInsertFile("photo",dlg.FileName) \'插入文件 Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") pic.Image = GetImage(dlg.FileName) Dim cmd As New SQLCommand cmd.C cmd.CommandText = "select * fr om {职员信息表} where sysid = \'" & dr("SysId") & "\'" Dim ct As DataTable = cmd.ExecuteReader Dim cr As DataRow = ct.Find("SysId= \'" & dr("SysId") & "\'") cr.SQLInsertFile("photo",dlg.FileName) End If End If
|
||||
-- 作者:有点蓝 -- 发布时间:2017/6/28 16:35:00 -- Dim ct As DataTable = cmd.ExecuteReader(true) |
||||
-- 作者:晕了快扶我 -- 发布时间:2017/6/28 16:50:00 -- 以下是引用有点蓝在2017/6/28 16:35:00的发言: Dim ct As DataTable = cmd.ExecuteReader(true) 没用的,试过了,因为cmd出来的表是临时表,用SQL的方式不行,提示没有datatable
|
||||
-- 作者:有点蓝 -- 发布时间:2017/6/28 17:16:00 -- sql更新用这种方式: Dim dr As DataRow = Tables("职员信息管理_职员信息表").Current.DataRow If dr IsNot Nothing Dim dlg As New OpenFileDialog dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png" If dlg.ShowDialog = DialogResult.OK Then dr.SQLInsertFile("photo",dlg.FileName) \'插入文件 Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1") Dim imgStream As New IO.MemoryStream Dim b As New Bitmap(pic.Image) b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Jpeg) Dim data As Byte() = imgStream.GetBuffer imgStream.Dispose() Dim conn As New System.Data.SqlClient.SqlConnection("server=localhost;database=test;Integrated Security=true;") \'改为自己的连接字符串 conn.Open() Dim sqlcomm As New System.Data.SqlClient.SqlCommand sqlcomm.Connection = conn sqlcomm.CommandText = "UPDATE [职员信息表] SET [photo] = @photo WHERE [sysid] = @sysid " sqlcomm.Parameters.Add("@photo", System.Data.SqlDbType.Image).Value = data sqlcomm.Parameters.Add("@sysid", System.Data.SqlDbType.NVarChar).Value = dr("SysId") sqlcomm.ExecuteNonQuery() conn.Close() End If End If 不然就加载表进来用吧
|