in stuednt admin i wan it to insert and also select from tbl_stuendadmin how to put it togeter

    If String.IsNullOrWhiteSpace(txtcard.Text) Or String.IsNullOrWhiteSpace(txtadmno.Text) Then
        MessageBox.Show("Please complete the on the box.", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
    End If

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

        If Conn.State = ConnectionState.Open Then Conn.Close()

        Dim sql As String = "insert into tbl_datain ([Stud Admin], [Admin Card]) values('" & txtadmno.Text & "', '" & txtcard.Text & "')"
        Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql, Conn)
        sqlCom.Connection = Conn

        Dim result As Integer = sqlCom.ExecuteNonQuery()


        If result > 0 Then
            MessageBox.Show("Successfully Register.")
            MessageBox.Show("Failure to create.")

        End If
        txtadmno.Text = ""
        txtcard.Text = ""

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

End Sub

You can create a command object with multiple SQL Statement. Like

Dim CMD As New System.Data.OleDb.OleDbCommand

CMD.CommandText = "Select * From Table1; Select * From Table2"

And you can work with every select statement one by one.

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