0% found this document useful (0 votes)
18 views2 pages

Exp 31 Doc

The document describes code for a college management system that connects to a database and displays student and class data in a dataset and datagrid. Buttons allow navigation between records and switching between tables.

Uploaded by

notlalit9308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Exp 31 Doc

The document describes code for a college management system that connects to a database and displays student and class data in a dataset and datagrid. Buttons allow navigation between records and switching between tables.

Uploaded by

notlalit9308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Imports System.Data.

OleDb
Public Class Exp25_26
Dim myCon As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\
CollegeManagementSystem.mdb")
Dim myDA As OleDbDataAdapter
Dim myCmd As OleDbCommand
Dim myDS As New DataSet
Dim myDT As DataTable
Dim rowCount As Integer = 0
Private Sub Exp25_26_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
myCmd = New OleDbCommand("Select * From StudentInfo", myCon)
myDA = New OleDbDataAdapter(myCmd)
myDA.Fill(myDS)
myCmd = New OleDbCommand("Select * From ClassInfo", myCon)
myDA = New OleDbDataAdapter(myCmd)
myDT = New DataTable()
myDA.Fill(myDT)
myDS.Tables.Add(myDT)
Display()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
DataGridView1.DataSource = myDS.Tables(1)
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
DataGridView1.DataSource = myDS.Tables(0)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If (rowCount = myDS.Tables(0).Rows.Count - 1) Then
rowCount = 0
Else
rowCount = rowCount + 1
End If
Display()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If (rowCount = 0) Then
rowCount = myDS.Tables(0).Rows.Count - 1
Else
rowCount = rowCount - 1
End If
Display()
End Sub
Private Sub Display()
TextBox1.Text = myDS.Tables(0).Rows(rowCount)(0)
TextBox2.Text = myDS.Tables(0).Rows(rowCount)(1)
TextBox3.Text = myDS.Tables(0).Rows(rowCount)(2)
TextBox4.Text = myDS.Tables(0).Rows(rowCount)(3)
TextBox5.Text = myDS.Tables(0).Rows(rowCount)(4)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
rowCount = myDS.Tables(0).Rows.Count - 1
Display()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
rowCount = 0
Display()
End Sub
End Class

You might also like