以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]图片保存到格元格的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=79811)

--  作者:荟美绘姿
--  发布时间:2016/1/9 15:43:00
--  [求助]图片保存到格元格的问题


图片点击可在新窗口打开查看此主题相关图片如下:qq截图20160109153210.png
图片点击可在新窗口打开查看

 

点击Button3控件时出现操作数类型冲突:image与nvarchar不兼容,以下代码哪里错了?

 

If Tables("wztz").Current Is Nothing Then
    Return
End If
Dim dr As DataRow = Tables("wztz").Current.DataRow
Dim dlg As New OpenFileDialog
dlg.Filter = "图形文件|*.bmp;*.jpg;*.gif;*.png"
If dlg.ShowDialog = DialogResult.OK Then
    dr.SQLInsertFile("wzzp",dlg.FileName) \'插入文件
    Dim pic As WinForm.PictureBox = e.Form.Controls("PictureBox1")
    pic.Image = GetImage(dlg.FileName)
End If

 

 

还有我想点击[保存]控件时把图片同时保存在“wzzp"单元格内,应该如何编写代码?

 If e.Form.Controls("ComboBox1").Text = "" Then
    MessageBox.Show("车牌颜色不能为空")
Return
End If
Tables("wztz").AddNew()
Tables("clxx").AddNew()
Tables("wztz").current("dwjbqh_dwmc")=e.Form.Controls("TextBox2").text
Tables("wztz").current("dwjbqh_dwdz")=e.Form.Controls("TextBox3").text
Tables("wztz").current("dwjbqh_lxdh")=e.Form.Controls("TextBox4").text
Tables("wztz").current("dwjbqh_yzbm")=e.Form.Controls("TextBox5").text
Tables("wztz").current("cljbqh_cphm")=e.Form.Controls("TextBox6").text
Tables("clxx").current("clhm")=e.Form.Controls("TextBox6").text
Tables("wztz").current("cljbqh_cpys")=e.Form.Controls("ComboBox1").text
Tables("clxx").current("cpys")=e.Form.Controls("ComboBox1").text
Tables("clxx").current("xlqh_qd")=e.Form.Controls("TextBox7").text
Tables("clxx").current("xlqh_zd")=e.Form.Controls("TextBox10").text
Tables("clxx").current("xltjd")=e.Form.Controls("TextBox11").text
Tables("wztz").current("wzjbqh_wzxw")=e.Form.Controls("ComboBox2").text
Tables("wztz").current("wzjbqh_wzdd")=e.Form.Controls("ComboBox3").text
Tables("wztz").current("wzjbqh_wzsj")=e.Form.Controls("DateTimePicker1").text
Tables("wztz").current("clhj")=e.Form.Controls("ComboBox4").text
Tables("wztz").current("yjbm")=e.Form.Controls("ComboBox5").text
Tables("wztz").current("ajly")=e.Form.Controls("ComboBox6").text
Tables("wztz").current("cfqh_ajzt")=e.Form.Controls("ComboBox7").text
Tables("wztz").current("cfqh_xfje")=e.Form.Controls("TextBox8").text
Tables("wztz").current("clfs")=e.Form.Controls("ComboBox8").text
Tables("wztz").current("wzzp")=e.Form.Controls("PictureBox1").text
DataTables("wztz").Save()
DataTables("clxx").Save()
DataTables("wztz").ReplaceFor("_Locked",True,"")
DataTables("clxx").ReplaceFor("_Locked",True,"")

 

请大侠们指教,谢谢

[此贴子已经被作者于2016/1/9 15:44:02编辑过]

--  作者:Hyphen
--  发布时间:2016/1/9 16:21:00
--  
Tables("wztz").current("wzzp")=e.Form.Controls("PictureBox1").ImageFile
--  作者:荟美绘姿
--  发布时间:2016/1/9 17:21:00
--  

 

在WZTZ表的CurrentChanged事件代码设置为:

If Forms("窗口1).Opened Then \'如果窗口已经打开
    Dim pbx As WinForm.PictureBox = Forms("窗口1").Controls("PictureBox1")
    If Tables("wztz").Current Is Nothing Then
        pbx.Image = Nothing
    Else
        pbx.Image = Tables("wztz").Current.DataRow.SQlLoadImage("wzzp") \'从后台提取照片并显示
    End
If
End
If

点击[保存]时出现提示:新增行必须先保存,才能提取或设置后台数据!

 

这是咋回事,请大侠帮解决一下下,谢谢!

[此贴子已经被作者于2016/1/9 17:30:33编辑过]

--  作者:大红袍
--  发布时间:2016/1/10 12:20:00
--  

意思是,如果当前行是新增的行,不能执行 SQlLoadImage 啊。

 

判断行的状态,参考 http://www.foxtable.com/help/topics/0428.htm