‘==================通过复制新建了个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