Dim oConn As New Connection
Dim connStr As String
Dim oRs As New Recordset
Dim oRs1 As New Recordset
Dim oAs As New Stream
Dim oFso As New FileSystemObject
Dim webPath As String
connStr = "Provider=ORAOLEDB.Oracle;Data Source=" + Trim(Text1.Text) + ";user id=" + Trim(Text2.Text) + ";password=" + Text3.Text '向数据库插入数据,连接串必须用这个,用了其它几个,访问数据库,可以,用以下方式,插入数据就有问题....
If oConn.State = adStateOpen Then
MsgBox "连接成功!", vbOKOnly, "温馨提示"
Else
MsgBox "连接出错!", vbOKOnly, "错误提示"
End If
Private Sub Form_Load()
Set obj = CreateObject("spy.database")
oAs.Type = 1
oAs.Mode = 3
Text4.Text = Dir1.Path
End Sub
Private Sub Dir1_Change()
On Error Resume Next
Text4.Text = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
If Err <> 0 Then
MsgBox "请选择有效磁盘!", vbOKOnly, "错误提示"
End If
End Sub
Public Function clname(cfname As String) As String
On Error Resume Next
If Not IsNull(cfname) Then
cfnamearr = Split(cfname, "/")
clname = cfnamearr(UBound(cfnamearr))
Else
clname = ""
End If
End Function
'插入
webPath = Text4.Text '得到路径
'MsgBox Text4.Text + "/Manmanager/photo"
If Not oFso.FolderExists(webPath + "/Manmanager/photo") Then
MsgBox "系统安装路径选择出错,请重新选择!"
Exit Sub
End If
Dim oStr1 As String
oStr1 = "select manid,fpath from tblszman where fpath is not null"
oRs1.Open oStr1, oConn, 1, 1
While Not oRs1.EOF
ostr = "select * from tblszmantu where manid='" + clname(oRs1("manid")) + "'"
oRs.Open ostr, oConn, 1, 3
If oRs.EOF Then
photoname = clname(oRs1("fpath"))
If oFso.FileExists(webPath + "/Manmanager/photo/" + photoname) Then
oAs.Open
oAs.LoadFromFile webPath + "/Manmanager/photo/" + photoname
oRs.AddNew
oRs("manid") = oRs1("manid")
oRs("fname") = photoname
oRs("fdata") = oAs.Read
oRs.Update
oAs.Close
End If
End If
oRs.Close
yscnum = yscnum + 1
wscnum = wscnum - 1
oRs1.MoveNext
Wend
s11 = CStr(scnum)
s12 = CStr(yscnum)
s13 = CStr(wscnum)
oRs1.Close
'没想过要导出,不过还是做了一个导出示例:
oAs.Open
ostr = "select * from temptu where pid='200610270002'"
oRs.Open ostr, oConn, 1, 3
oAs.Write oRs("fdata")
oAs.SaveToFile "C:/Documents and Settings/Administrator/My Documents/My Pictures/111.jpg", 2
oRs.Close
oAs.Close