‘==================通過復制新建了個access數據庫其中text.text放著CommonDialog1.FileName
Private Sub new_Click()
On Error GoTo Cancel
Dim FileName As String
Dim FileSystemObject As Object
CommonDialog1.Filter = "microsoft access 數據庫(*.mdb)|*.mdb"
CommonDialog1.Action = 2
Text1.Text = CommonDialog1.FileName
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
FileSystemObject.CopyFile "C:\Users\admin\Desktop\tycs.mdb", Text1.Text
Cancel:
End Sub‘’‘查看已有該文件
’===============在連接數據庫時
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Text1.Text"
rs.Open "select * from YJCS", cnn, adOpenKeyset, adLockOptimistic
系統顯示沒有該路徑
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Text1.Text"
改成
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & Text1.Text