Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strsql As String
        strsql = "select 用户名,密码 from 用户表 where 用户名 =" & TextBox1.Text & "and 密码 = " & TextBox2.Text & ""
        Dim myconn As New OleDb.OleDbConnection
        Dim mycomm As New OleDb.OleDbCommand
        Dim myadpt As New OleDb.OleDbDataAdapter
        Dim myds As New DataSet
        Try
            If TextBox1.Text = "" Or TextBox2.Text = "" Then
                MsgBox("用户名不能为空!")
                TextBox1.Focus()
                TextBox2.Text = Nothing
                Exit Sub
            End If
            myconn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source = 通讯录.mdb;fersist security info=false"
            myconn.Open()
            mycomm.CommandText = strsql
            mycomm.Connection = myconn
            myadpt.SelectCommand = mycomm
            myadpt.Fill(myds)
            Dim mytable As New DataTable
            mytable = myds.Tables(0)
            If mytable.Rows.Count = 0 Then
                MsgBox("用户名或密码输入错误!请重新输入!")
                TextBox1.Focus()
                TextBox1.SelectAll()
                TextBox2.Text = ""
            Else
                blnok = True
                Me.Close()
            End If
        Catch ex As Exception
            MsgBox(ex.ToString)
        Finally
            myconn.Close()
        End Try
        主窗体.Show()
    End Sub
这是我的代码错误是找不到isam 

解决方案 »

  1.   

    正确的:
    myconn.ConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & txtMdbPath & ";Persist Security Info=False"你的代码(指定MDB文件的路径):
    myconn.ConnectionString="provider=microsoft.jet.oledb.4.0;data source =“& app.path & "\通讯录.mdb;fersist security info=false"
      

  2.   

    myconn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source = 通讯录.mdb;fersist security info=false"
    *******************************************
    trymyconn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source = " & Application.StartupPath & "\通讯录.mdb;persist security info=false"
      

  3.   

    http://download.csdn.net/source/1498324