sinat_26793923
sinat_26793923
采纳率33.3%
2015-05-28 03:52 阅读 1.9k
已采纳

vb 连接access数据库路径问题

‘==================通过复制新建了个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
系统显示没有该路径
图片说明

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    gamefinity 知常曰明 2015-05-28 03:59
     cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = Text1.Text"
    

    改成

    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" & Text1.Text
    
    点赞 评论 复制链接分享

相关推荐