VB读取照片的问题
我将照片放在服务器的文件夹里,在数据库里存放了路径,且数据库里有存放的信息了,但确读不出来,请帮忙指点下,问题是什么“DimiConcstrAsStringDimiCon...
我将照片放在服务器的文件夹里,在数据库里存放了路径,且数据库里有存放的信息了,但确读不出来,请帮忙指点下,问题是什么“
Dim iConcstr As String
Dim iConc As ADODB.Connection
'保存文件到数据库中
Sub s_SaveFile()
Dim iRe As ADODB.Recordset
Dim iConcstr As String
'打开保存文件的表
Set iRe = New ADODB.Recordset
With iRe
.Open "select * from imge", iConc, 1, 3
.AddNew '新增一条记录
.Fields("photo") = "wenjinmin"
.Update
End With
'完成后关闭对象
iRe.Close
Image1.Picture = LoadPicture() '清空
End Sub
Sub s_ReadFile()
Dim iRe As ADODB.Recordset
'打开表
Set iRe = New ADODB.Recordset
'得到最新添加的纪录
iRe.Open "select * from imge ", iConc, adOpenKeyset, adLockReadOnly
If iRe.EOF Then '指针指向最后一条记录
iRe.MoveFirst
End If
Image1.Picture = LoadPicture(iRe.Fields("photo").Value) '这里有问题说“类型不匹配 13”
'关闭对象
iRe.Close
End Sub
Private Sub Command1_Click() ‘读取图片到image
Call s_ReadFile
End Sub
Private Sub Command2_Click() ’保存文件路径打数据库imge表的“PHOTO”列
Call s_SaveFile
End Sub
Private Sub Command3_Click() ‘打开文件夹,选择图片到image
CommonDialog1.Filter = "图片文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen '显示打开文件对话框
wenjinmin = CommonDialog1.FileName '取得整个文件的存放路径
Image1.Picture = LoadPicture(wenjinmin)
End Sub
Private Sub Form_Load()
'下面的语句是连接sqlserver数据库的.
iConcstr = "rovider=SQLOLEDB.1ersist Security Info=True;" & _
"User ID=saassword=sa;Initial Catalog=db_hsjs;Data Source=127.0.0.1"
Set iConc = New ADODB.Connection
iConc.Open iConcstr
End Sub
Private Sub Form_Unload(Cancel As Integer)
iConc.Close
Set iConc = Nothing
End Sub 展开
Dim iConcstr As String
Dim iConc As ADODB.Connection
'保存文件到数据库中
Sub s_SaveFile()
Dim iRe As ADODB.Recordset
Dim iConcstr As String
'打开保存文件的表
Set iRe = New ADODB.Recordset
With iRe
.Open "select * from imge", iConc, 1, 3
.AddNew '新增一条记录
.Fields("photo") = "wenjinmin"
.Update
End With
'完成后关闭对象
iRe.Close
Image1.Picture = LoadPicture() '清空
End Sub
Sub s_ReadFile()
Dim iRe As ADODB.Recordset
'打开表
Set iRe = New ADODB.Recordset
'得到最新添加的纪录
iRe.Open "select * from imge ", iConc, adOpenKeyset, adLockReadOnly
If iRe.EOF Then '指针指向最后一条记录
iRe.MoveFirst
End If
Image1.Picture = LoadPicture(iRe.Fields("photo").Value) '这里有问题说“类型不匹配 13”
'关闭对象
iRe.Close
End Sub
Private Sub Command1_Click() ‘读取图片到image
Call s_ReadFile
End Sub
Private Sub Command2_Click() ’保存文件路径打数据库imge表的“PHOTO”列
Call s_SaveFile
End Sub
Private Sub Command3_Click() ‘打开文件夹,选择图片到image
CommonDialog1.Filter = "图片文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen '显示打开文件对话框
wenjinmin = CommonDialog1.FileName '取得整个文件的存放路径
Image1.Picture = LoadPicture(wenjinmin)
End Sub
Private Sub Form_Load()
'下面的语句是连接sqlserver数据库的.
iConcstr = "rovider=SQLOLEDB.1ersist Security Info=True;" & _
"User ID=saassword=sa;Initial Catalog=db_hsjs;Data Source=127.0.0.1"
Set iConc = New ADODB.Connection
iConc.Open iConcstr
End Sub
Private Sub Form_Unload(Cancel As Integer)
iConc.Close
Set iConc = Nothing
End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询