简体   繁体   中英

How to show data from ms access according to the ID that is typed in log in

Sorry I was not clear enough. I want to show the name of the user when he/she types his/her LRN in the textbox. The name must be shown on another form when the LRN is recognized from ms access.

Imports Microsoft.VisualBasic

Public Class Class1
    Private Sub GunaButton1_Click(
        sender As Object, e As EventArgs
    ) Handles GunaButton1.Click

        Dim connection
            As New OleDbConnection(
                "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database4.mdb"
            )

        connection.Open()

        Dim cmd As OleDbCommand = 
            New OleDbCommand(
                "select * from Table1 where [Lrn]='" 
                & GunaTextBox1.Text & "'", connection
            )

        Dim loginrd As OleDbDataReader = cmd.ExecuteReader

        If (loginrd.Read() = True) Then
            Me.Hide()

            With Form16
                .TopLevel = False
                Form5.GunaPanel2.Controls.Add(Form16)
                .BringToFront()
                .Show()

            End With

            MessageBox.Show(
                "Login Successful!", "Login Message", MessageBoxButtons.OK
            )
        Else
            MsgBox(
                "Sorry. The LRN you entered is invalid.", MsgBoxStyle.Critical
            )
        End If
    End Sub
End Class

It's hard to understand what you're trying to do, but i think your problem is how to pass data from one form to another. If that is the case just see this example.

Do it like this, create 2 forms with the names: FormLogin and FormAfterLogin. In FormLogin put a button and in FormAfterLogin put a textbox.

Double click the button in FormLogin and write this code:

Sub Button1_Click (......)
    FormAfterLogin.LoadForm ("this is the data that i want to pass.")
    Me.Close
End sub

In FormAfterLogin insert this code:

Sub LoadForm (sName as string)
    textbox1.text=sName
    me.show
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM