关于vb2010连接.mdb文件

时间:2012-04-05 12:42:12

标签: vb.net connection-string

我做了vb作业 首先,连接mdb文件,然后登录 在mdb文件中,有登录帐户和密码 当我运行该程序时,它有一些问题:
“dataAdapter.Fill(dt)”突出显示,“Microsoft.Jet.OLEDB.4.0xxxxxxx.mdb”提供程序未在本地计算机上注册。

Private Sub loginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loginButton.Click
    Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0" & "Data Source=xxxxxxx.mdb"
    Dim sqlStr As String = "Select * from account"
    Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
    dataAdapter.Fill(dt)
    dataAdapter.Dispose()

    For i As Integer = 0 To (dt.Rows.Count - 1)
        If TextBox1.Text = CStr(dt.Rows(i)("accountid")) And TextBox2.Text = CStr(dt.Rows(i)("password")) Then
            login = True
        End If
    Next

    If login = True Then
        MsgBox("logined")
    Else
        MsgBox("Incorrect username or password. Please try again.")
        TextBox1.Clear()
        TextBox2.Clear()
    End If

1 个答案:

答案 0 :(得分:1)

您在连接字符串中缺少分号(;)。