how i put it like i am a student so i choose student and key in username n password, if choose worng like i click lectuere but i not, so cant is worng cant login

Private Sub cbinfo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbinfo.SelectedIndexChanged

    Dim conn As New System.Data.OleDb.OleDbConnection()
    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\temp\Database1.accdb"

    Try
        Dim sqlcmd As String = "SELECT Count(*) FROM tbl_datain WHERE Personl ='" & cbinfo.Items(cbinfo.SelectedIndex) & "' " & _
         "And UserID ='" & txtname.Text & "' And PassWord ='" & txtpass.Text & "'"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sqlcmd)
        sqlCom.Connection = conn
        conn.Open()

        Dim Result As Integer = sqlCom.ExecuteScalar
        sqlCom.Dispose()
        conn.Close()

        If Result > 0 Then


            MessageBox.Show("Present")

        Else
            MessageBox.Show("Wrong Input")
        End If

    Catch ex As Exception
    End Try

    Catch ex As Exception
    End Try

Recommended Answers

All 2 Replies

Just from a quick glance see if this helps: cbinfo.Items(cbinfo.SelectedIndex).ToString().

thank. but if worng input should not come another form of the student info how to do that only when corrct then come out the other form.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.