我在打开时收到错误

时间:2015-11-13 23:11:03

标签: vb.net

Public Class Form4
    Dim objcon As New OleDbConnection
    Dim strSQL As String
    Dim strconnection As String = "provider=microsoft.ACE.OLEDO.12.0;Data Source=shweta:\WindowsApplication1\Databaseapp.accdb"
    Dim da As New OleDbDataAdapter
    Dim ds As New DataSet
    Dim attempt As Integer = 0

    Private Sub btnsignin_Click(sender As Object, e As EventArgs) Handles btnsignin.Click
        Dim strName = txtpassword.Text
        Dim strpass = txtpassword.Text
        With objcon
            .Close()
            If .State = ConnectionState.Closed Then
                .ConnectionString = strconnection
                .Open()
                '{they r showing An unhandled exception of type 
                'System.InvalidOperationException' occurred in 
                ' System.Data.dll  }}
                MsgBox("connectionstate.open", MsgBoxStyle.Information, "connected")


            End If
        End With
        ds.Clear()
        strSQL = "Select * from logintable where username='" & Txtusername.Text & "' And password =''" & txtpassword.Text '"
        da = New OleDbDataAdapter(strSQL, objcon)
        da.Fill(ds, "logintable")
        If ds.Tables("logintable").Rows.Count <> 0 Then
            MaximizeBox = True
            MinimizeBox = True
        Else
            MaximizeBox = False
            MinimizeBox = False
            MessageBox.Show("invalid")

        End If
        Form2.Show()
        Me.Hide()
    End Sub
End Class

1 个答案:

答案 0 :(得分:-2)

以下是错误修正:

  1. 如果可以Imports System.Data.OleDb之前放置Public Class Form4,那就有效。
  2. 另外,在form4块中添加Public Property Form2 As Object
  3. 仍有部分代码丢失。你能说明一下吗?