'此处如何显示图片,图片使用了picture控件.Private Sub Form_Load()
Dim txtSQL, MsgText As String
Dim intCount As Integer
Dim pid As Integer
Dim mrc As ADODB.Recordset
intCount = ProductView.myFlexgrid.Row
txtSQL = "select *,(select class from class where id=product.rllx) as rllxname,(select class from class where id=product.ltcz) as ltczname,(select class from class where id=product.gllx) as gllxname,(select class from class where id=product.ltlx) as ltlxname from product where id=" & Trim(ProductView.myFlexgrid.TextMatrix(intCount, 0)) & ""
'MsgBox txtSQL
Set mrc = ExecuteSQL(txtSQL, MsgText)
glmc.Caption = mrc.Fields("glmc").Value '锅炉名称
gllx.Caption = mrc.Fields("gllxname").Value '锅炉类型
yt.Caption = mrc.Fields("yt").Value '用途
rllx.Caption = mrc.Fields("rllxname").Value 'mrc.Fields("rllx").Value '燃料类型
ltcz.Caption = mrc.Fields("ltczname").Value '炉体材质
syrl.Caption = mrc.Fields("syrl").Value '适用燃料
ltlx.Caption = mrc.Fields("ltlxname").Value '炉体类型
jg.Caption = mrc.Fields("jg").Value '结构
yyfw.Caption = mrc.Fields("yyfw").Value '应用范围
xntd.Caption = mrc.Fields("xntd").Value '性能特点
xh.Caption = mrc.Fields("xh").Value '型号
rgl.Caption = mrc.Fields("rgl").Value '热功率
zfl.Caption = mrc.Fields("zfl").Value '蒸发量
zqwd.Caption = mrc.Fields("zqwd").Value '蒸汽温度
gswd.Caption = mrc.Fields("gswd").Value '给水温度
gywd.Caption = mrc.Fields("gywd").Value '供油温度
yrl.Caption = mrc.Fields("yrl").Value '油容量
xhyl.Caption = mrc.Fields("xhyl").Value '循环油量
rgl2.Caption = mrc.Fields("rgl2").Value '热功率
hcyl.Caption = mrc.Fields("hcyl").Value '耗柴油量
htrql.Caption = mrc.Fields("htrql").Value '耗天然气量
hml.Caption = mrc.Fields("hml").Value '耗煤量
hdl.Caption = mrc.Fields("hdl").Value '耗电量
gzyl.Caption = mrc.Fields("gzyl").Value '蒸汽压力
rxl.Caption = mrc.Fields("rxl").Value '热效率
ghswd.Caption = mrc.Fields("ghswd").Value '供回水温度
srl.Caption = mrc.Fields("srl").Value '有效水容积
cnmj.Caption = mrc.Fields("cnmj").Value '采暖面积
xyrs.Caption = mrc.Fields("xyrs").Value '洗浴人数
gksl.Caption = mrc.Fields("gksl").Value '供开水量
ltzl.Caption = mrc.Fields("ltzl").Value '炉体重量
wxcc.Caption = mrc.Fields("wxcc").Value '外形尺寸
jiage.Caption = mrc.Fields("jiage").Value '价格
id.Caption = mrc.Fields("id").Value '产品ID号
'此处如何显示图片,图片使用了picture控件.
mrc.Close
End Sub
Dim txtSQL, MsgText As String
Dim intCount As Integer
Dim pid As Integer
Dim mrc As ADODB.Recordset
intCount = ProductView.myFlexgrid.Row
txtSQL = "select *,(select class from class where id=product.rllx) as rllxname,(select class from class where id=product.ltcz) as ltczname,(select class from class where id=product.gllx) as gllxname,(select class from class where id=product.ltlx) as ltlxname from product where id=" & Trim(ProductView.myFlexgrid.TextMatrix(intCount, 0)) & ""
'MsgBox txtSQL
Set mrc = ExecuteSQL(txtSQL, MsgText)
glmc.Caption = mrc.Fields("glmc").Value '锅炉名称
gllx.Caption = mrc.Fields("gllxname").Value '锅炉类型
yt.Caption = mrc.Fields("yt").Value '用途
rllx.Caption = mrc.Fields("rllxname").Value 'mrc.Fields("rllx").Value '燃料类型
ltcz.Caption = mrc.Fields("ltczname").Value '炉体材质
syrl.Caption = mrc.Fields("syrl").Value '适用燃料
ltlx.Caption = mrc.Fields("ltlxname").Value '炉体类型
jg.Caption = mrc.Fields("jg").Value '结构
yyfw.Caption = mrc.Fields("yyfw").Value '应用范围
xntd.Caption = mrc.Fields("xntd").Value '性能特点
xh.Caption = mrc.Fields("xh").Value '型号
rgl.Caption = mrc.Fields("rgl").Value '热功率
zfl.Caption = mrc.Fields("zfl").Value '蒸发量
zqwd.Caption = mrc.Fields("zqwd").Value '蒸汽温度
gswd.Caption = mrc.Fields("gswd").Value '给水温度
gywd.Caption = mrc.Fields("gywd").Value '供油温度
yrl.Caption = mrc.Fields("yrl").Value '油容量
xhyl.Caption = mrc.Fields("xhyl").Value '循环油量
rgl2.Caption = mrc.Fields("rgl2").Value '热功率
hcyl.Caption = mrc.Fields("hcyl").Value '耗柴油量
htrql.Caption = mrc.Fields("htrql").Value '耗天然气量
hml.Caption = mrc.Fields("hml").Value '耗煤量
hdl.Caption = mrc.Fields("hdl").Value '耗电量
gzyl.Caption = mrc.Fields("gzyl").Value '蒸汽压力
rxl.Caption = mrc.Fields("rxl").Value '热效率
ghswd.Caption = mrc.Fields("ghswd").Value '供回水温度
srl.Caption = mrc.Fields("srl").Value '有效水容积
cnmj.Caption = mrc.Fields("cnmj").Value '采暖面积
xyrs.Caption = mrc.Fields("xyrs").Value '洗浴人数
gksl.Caption = mrc.Fields("gksl").Value '供开水量
ltzl.Caption = mrc.Fields("ltzl").Value '炉体重量
wxcc.Caption = mrc.Fields("wxcc").Value '外形尺寸
jiage.Caption = mrc.Fields("jiage").Value '价格
id.Caption = mrc.Fields("id").Value '产品ID号
'此处如何显示图片,图片使用了picture控件.
mrc.Close
End Sub
我使用Picture1.Picture=LoadPicture(mrc.field("picture"))时提示路径什么的。
打开vb6,新建工程。添加两个按钮,一个image控件
注意:Access中的photo字段类型为OLE对象.
SqlServer中的photo字段类型为Image'** 引用 Microsoft ActiveX Data Objects 2.5 Library 及以上版本
‘2.5版本以下不支持Stream对象
Dim iConcstr As String
Dim iConc As ADODB.Connection
'保存文件到数据库中
Sub s_SaveFile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
Dim iConcstr As String '读取文件到内容
Set iStm = New ADODB.Stream
With iStm
.Type = adTypeBinary '二进制模式
.Open
.LoadFromFile App.Path + "\test.jpg"
End With
'打开保存文件的表
Set iRe = New ADODB.Recordset
With iRe
.Open "select * from img", iConc, 1, 3
.AddNew '新增一条记录
.Fields("photo") = iStm.Read
.Update
End With
'完成后关闭对象
iRe.Close
iStm.Close
End Sub
Sub s_ReadFile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
'打开表
Set iRe = New ADODB.Recordset
‘得到最新添加的纪录
iRe.Open "select top 1 * from img order by id desc", iConc, adOpenKeyset, adLockReadOnly
'保存到文件
Set iStm = New ADODB.Stream
With iStm
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write iRe("photo")
‘这里注意了,如果当前目录下存在test1.jpg,会报一个文件写入失败的错误.
.SaveToFile App.Path & "\test1.jpg"
End With
Image1.Picture = LoadPicture(App.Path & "\test1.jpg")
'关闭对象
iRe.Close
iStm.Close
End Sub
Private Sub Command1_Click()
Call s_ReadFile
End Sub
Private Sub Command2_Click()
Call s_SaveFile
End Sub
Private Sub Form_Load()
'数据库连接字符串
iConcstr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _
";Data Source=F:\csdn_vb\database\保存图片\access图片\img.mdb"‘下面的语句是连接sqlserver数据库的.
‘iConcstr = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _
‘ "User ID=sa;Password=;Initial Catalog=test;Data Source=yang"
Set iConc = New ADODB.Connection
iConc.Open iConcstr
End Sub
Private Sub Form_Unload(Cancel As Integer)
iConc.Close
Set iConc = Nothing
End Sub
打开vb6,新建工程。添加两个按钮,一个image控件
注意:Access中的photo字段类型为OLE对象.
SqlServer中的photo字段类型为Image'** 引用 Microsoft ActiveX Data Objects 2.5 Library 及以上版本
‘2.5版本以下不支持Stream对象
Dim iConcstr As String
Dim iConc As ADODB.Connection
'保存文件到数据库中
Sub s_SaveFile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
Dim iConcstr As String '读取文件到内容
Set iStm = New ADODB.Stream
With iStm
.Type = adTypeBinary '二进制模式
.Open
.LoadFromFile App.Path + "\test.jpg"
End With
'打开保存文件的表
Set iRe = New ADODB.Recordset
With iRe
.Open "select * from img", iConc, 1, 3
.AddNew '新增一条记录
.Fields("photo") = iStm.Read
.Update
End With
'完成后关闭对象
iRe.Close
iStm.Close
End Sub
Sub s_ReadFile()
Dim iStm As ADODB.Stream
Dim iRe As ADODB.Recordset
'打开表
Set iRe = New ADODB.Recordset
‘得到最新添加的纪录
iRe.Open "select top 1 * from img order by id desc", iConc, adOpenKeyset, adLockReadOnly
'保存到文件
Set iStm = New ADODB.Stream
With iStm
.Mode = adModeReadWrite
.Type = adTypeBinary
.Open
.Write iRe("photo")
‘这里注意了,如果当前目录下存在test1.jpg,会报一个文件写入失败的错误.
.SaveToFile App.Path & "\test1.jpg"
End With
Image1.Picture = LoadPicture(App.Path & "\test1.jpg")
'关闭对象
iRe.Close
iStm.Close
End Sub
Private Sub Command1_Click()
Call s_ReadFile
End Sub
Private Sub Command2_Click()
Call s_SaveFile
End Sub
Private Sub Form_Load()
'数据库连接字符串
iConcstr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False" & _
";Data Source=F:\csdn_vb\database\保存图片\access图片\img.mdb"‘下面的语句是连接sqlserver数据库的.
‘iConcstr = "Provider=SQLOLEDB.1;Persist Security Info=True;" & _
‘ "User ID=sa;Password=;Initial Catalog=test;Data Source=yang"
Set iConc = New ADODB.Connection
iConc.Open iConcstr
End Sub
Private Sub Form_Unload(Cancel As Integer)
iConc.Close
Set iConc = Nothing
End Sub