hi all i VB how to get the student inforamtion when the user have login from the access database?

You allready create and save a new user in your earlier Posting.
Use that conception, only change the "Insert" Statement by "Select" Statement in SQL statement.
To make confirmation whether the user is valid or not you can use it.

Try
            If Conn.State = ConnectionState.Open Then Conn.Close()
            Conn.Open()
            Dim sql As String = "Select Count(*) From tbl_datain Where [UserID] ='" & txtid.Text & "', And [PassWord]) ='" & txtword.Text & "'"
            Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
            sqlCom.Connection = Conn
            Dim result As Integer = sqlCom.ExecuteScalar()
            sqlCom.Dispose()
            Conn.Close()
            If result > 0 Then
                MessageBox.Show("Valid user.")
            Else
                MessageBox.Show("No existance")
            End If
            txtid.Text = ""
            txtword.Text = ""
            txtid.Focus()
        Catch ex As Exception
            MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

And other codes are same as you did in your earlier posting. Put it in LogIn Form's ButtonOK Click Event.

In SQL (STRUCTURED QUERY LANGUAGE),there are four(4) types of command statements.

1) DDL -> DATA DEFINITION LANGUAGE STATEMENTS (TO Use ->Create, Alter, Drop Databases)
2) DML ->DATA MANIPULATION LANGUAGE STATEMENTS (TO USE ->Insert, Update, Delete Data into/withen a table)
3) DCL -> DATA CONTROL LANGUAGE STATEMENT (USE TO ->Commit, RollBack, Grant for various type of works )
4) DQL ->DATA QUERY LANGUAGE STATEMENT (USE TO -> Retrieve Data forom the database by Select Statement)

So, to retrieve data you will have to use always DQL Statement like "Select FildNames From TableName Where FieldName = Value" as my above post. There the codes were how to count matching data in database, but there are a little difference to read every field and show them. The codes I post here, that can help you to grow a conception.

Try
            If Conn.State = ConnectionState.Open Then Conn.Close()
            Conn.Open()
            Dim sql As String = "Select [UserName], [UserAddress], [UserEmail] From tbl_datain Where [UserID] ='" & txtid.Text & "'"
            Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
            sqlCom.Connection = Conn
            Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()

            If sqlReader.HasRows Then
                sqlReader.Read()
                txtUName.Text = sqlReader.Item(0)
                txtAddress.Text = sqlReader.Item(1)
                txtEmail.Text = sqlReader.Item(2)
            End If
            sqlReader.Close()
            sqlCom.Dispose()
            Conn.Close()

        Catch ex As Exception
            MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

Declaring OleDbConnection variable and assirning its ConnectionString Property value are same as you did above.
Change your Table Name, Field names, TextBoxs or Controls Names as per your requirments.
But in the above codes you can get only the first matched record.
If you have to show a bunch of records how do you do this.
Here I take an example. Suppose you will have to add & show all user name in a
ListBox. How do you do. here I show you how it can do.

Try
            LBoxUName.Items.Clear()
            If Conn.State = ConnectionState.Open Then Conn.Close()
            Conn.Open()
            Dim sql As String = "Select Distinct [UserName] From tbl_datain"
            Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
            sqlCom.Connection = Conn
            Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()

            If sqlReader.HasRows Then
                Do While sqlReader.Read
                    LBoxUName.Items.Add(sqlReader.Item(0))
                Loop
            End If
            sqlReader.Close()
            sqlCom.Dispose()
            Conn.Close()

        Catch ex As Exception
            MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try

In Do - Loop DataReader automatically goes through the records. But it never give you any chance to go backward always in forward. When you open a DataReader it always Starts at the begining point.

Edited 2 Years Ago by Shark_1

(after login it cant get the database)

Private Sub infoForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

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

    Try
        If conn.State = ConnectionState.Open Then conn.Close()
        conn.Open()
        Dim sql As String = "Select [UserName], [UserAdminNo],[UserCourse Title],[UserIC No],[UserGender], [UserAddress],[UserData of Birth ],[UserTel No],[UserEmail], [UserType] From tbl_datain Where [UserID] ='" & txtname.Text & "'"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, conn)
        sqlCom.Connection = conn
        Dim sqlReader As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()

        If sqlReader.HasRows Then
            sqlReader.Read()
            txtname.Text = sqlReader.Item(0)
            txtadmin.Text = sqlReader.Item(1)
            txtcourse.Text = sqlReader.Item(2)
            txtic.Text = sqlReader.Item(3)
            txtgender.Text = sqlReader.Item(4)
            txtaddress.Text = sqlReader.Item(5)
            txtbirth.Text = sqlReader.Item(6)
            txttel.Text = sqlReader.Item(7)
            txtemail.Text = sqlReader.Item(8)
            txttpye.Text = sqlReader.Item(9)
        End If
        sqlReader.Close()
        sqlCom.Dispose()
        conn.Close()
        Catch ex As Exception
        MessageBox.Show("Failed to connect to Database..", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

Edited 2 Years Ago by Xiao_1

    Dim sql As String = "Select [UserName], [UserAdminNo],[UserCourse Title],[UserIC No],[UserGender], [UserAddress],[UserData of Birth ],[UserTel No],[UserEmail], [UserType] From tbl_datain Where [UserID] ='" & txtname.Text & "'"

([UserID] ='" & txtname.Text) Are your UserID and UserName same?

Edited 2 Years Ago by Shark_1

This article has been dead for over six months. Start a new discussion instead.