各位高手:
我做的程序要实现从数据库读取存入图片,请问怎样做。谢谢了。以下是我做的程序。
commond1_click事件使用通用对话框实现选取图片,利用image控件显示所选图片
commond2_click事件实现读取图片文件并保存到数据库,但是提示错误:“实时错误‘3704’,对象关闭时,操作不被允许”
Public filename As String
Private Sub Command1_Click()
CommonDialog1.DefaultExt = "*.*"
CommonDialog1.Filter = "所有文件(*.*)│*.*"
CommonDialog1.InitDir = "d:\网站\程序代码\travel3\pic"
CommonDialog1.ShowOpen
CommonDialog1.CancelError = True
filename = CommonDialog1.filename
Text1.Text = filename
Image1.Picture = LoadPicture(Text1.Text)
End Sub
Private Sub Command2_Click()
Dim filenum As Integer
Dim conn As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim str As String
str = "driver={sql server};server=wcg;uid=sa;pwd=;database=销售质量异议"
conn.Open str
str = "select * from zhlyy2"
rs1.Open str, conn, adOpenDynamic, adLockPessimistic
Dim mstream As ADODB.Stream
filenum = FreeFile
Open filename For Input As #filenum
Set mstream = New ADODB.Stream
mstream.LoadFromFile (Text1.Text)
rs1.Fields("tupian") = mstream.Read
rs1.Update
Close #filenum
End Sub
[此贴子已经被作者于2006-5-29 11:50:11编辑过]