Definitions:

 

Public Class frmDef

Inherits System.Windows.Forms.Form

Dim aTable As New DataTable

Dim aRow As DataRow

Dim aColumn As DataColumn

 

Private Sub btnColumns_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnColumns.Click

For Each aColumn In aTable.Columns

lstColumns.Items.Add(aColumn.ColumnName)

Next

End Sub

 

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

OleDbDataAdaptertablestu.Fill(aTable)

End Sub

 

Private Sub btnRows_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRows.Click

For Each aRow In aTable.Rows

lstRows.Items.Add(aRow.Item(0))

Next

For Each aRow In aTable.Rows

lstViewRows.Items.Add(aRow.Item("idno"))

Next

End Sub

End Class

 

ADObinding

 

Public Class frmBind

Inherits System.Windows.Forms.Form

Private currMang As CurrencyManager

 

 

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

daStudent.Fill(DsStudent1)

currMang = Me.BindingContext(DsStudent1, "tablestu")

End Sub

 

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

'currMang.Position = currMang.Position + 1

currMang.Position += 1

End Sub

 

Private Sub butLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butLast.Click

currMang.Position = currMang.Count - 1

End Sub

 

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click

currMang.Position = 0

End Sub

 

Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

'currMang.Position = currMang.Position - 1

currMang.Position -= 1

End Sub

End Class

 

Updating ADOAdd

 

Public Class frmAdd

Inherits System.Windows.Forms.Form

Private currMang As CurrencyManager

 

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

currMang.Position += 1

End Sub

 

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

daStudent.Fill(DsStudent1)

currMang = Me.BindingContext(DsStudent1, "tablestu")

End Sub

 

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click

currMang.Position = 0

End Sub

 

Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

currMang.Position -= 1

End Sub

 

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click

currMang.Position = currMang.Count - 1

End Sub

 

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

Dim newRecord As dsStudent.tablestuRow

newRecord = DsStudent1.tablestu.NewRow

newRecord.idno = InputBox("Enter idno", "New Record")

newRecord.name = InputBox("Enter name", "New Record")

newRecord.major = InputBox("Enter major", "New Record")

newRecord.city = InputBox("Enter city", "New Record")

newRecord.state = InputBox("Enter state", "New Record")

newRecord.gpa = CSng(InputBox("Enter GPA", "New Record"))

newRecord.yrentered = InputBox("Enter Year Entered", "New Record")

newRecord.credits = CInt(InputBox("Enter credits", "New Record"))

DsStudent1.tablestu.Rows.Add(newRecord)

End Sub

 

Private Sub btnAddDatabase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddDatabase.Click

daStudent.Update(DsStudent1)

End Sub

 

Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click

Me.Close()

End Sub

End Class

 

Adding and deleting

 

Public Class frmUpdate

Inherits System.Windows.Forms.Form

Private currMang As CurrencyManager

 

Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click

currMang.Position = currMang.Count - 1

End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

currMang.Position += 1

End Sub

Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click

currMang.Position = 0

End Sub

Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click

currMang.Position -= 1

End Sub

 

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

daStudent.Fill(DsStudent1)

currMang = Me.BindingContext(DsStudent1, "tablestu")

End Sub

 

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

Dim newRecord As DsStudent.tablestuRow

newRecord = DsStudent1.tablestu.NewRow

newRecord.idno = InputBox("Enter idno", "New Record")

newRecord.name = InputBox("Enter name", "New Record")

newRecord.major = InputBox("Enter major", "New Record")

newRecord.city = InputBox("Enter city", "New Record")

newRecord.state = InputBox("Enter state", "New Record")

newRecord.gpa = CSng(InputBox("Enter GPA", "New Record"))

newRecord.yrentered = InputBox("Enter Year Entered", "New Record")

newRecord.credits = CInt(InputBox("Enter credits", "New Record"))

DsStudent1.tablestu.Rows.Add(newRecord)

End Sub

 

Private Sub btnChangeDatabase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangeDatabase.Click

daStudent.Update(DsStudent1)

End Sub

 

Private Sub btnEnd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnd.Click

Me.Close()

End Sub

 

Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

currMang.RemoveAt(currMang.Position)

End Sub

End Class

 

ADOgrid

 

Public Class frmStu

Inherits System.Windows.Forms.Form

 

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

daStudent.Fill(DsStudent1)

End Sub

 

Private Sub btnWriteDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWriteDB.Click

Dim cellHold As DataGridCell = dgdStudent.CurrentCell

If dgdStudent.CurrentRowIndex > 0 Then

dgdStudent.CurrentCell = New DataGridCell(0, 0)

Else

dgdStudent.CurrentCell = New DataGridCell(1, 0)

End If

daStudent.Update(DsStudent1)

dgdStudent.CurrentCell = cellHold

End Sub

End Class

 

ADOgridcode

 

Public Class frmGridCode

Inherits System.Windows.Forms.Form

Dim conStudent As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source = C:\VBver6\VB98\Access2000\stu2000.mdb"

Dim sqlStr As String = "Select idno, name, major, city, state, gpa, yrentered, credits from tablestu order by idno"

Dim daStudent As New OleDb.OleDbDataAdapter(sqlStr, conStudent)

Dim studentDT As New DataTable

 

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

daStudent.Fill(studentDT)

dgdStudent.DataSource = studentDT

 

End Sub

 

Private Sub btnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrite.Click

Dim cellHold As DataGridCell = dgdStudent.CurrentCell

If dgdStudent.CurrentRowIndex > 0 Then

dgdStudent.CurrentCell = New DataGridCell(0, 0)

Else

dgdStudent.CurrentCell = New DataGridCell(1, 0)

End If

daStudent.Update(studentDT)

dgdStudent.CurrentCell = cellHold

End Sub

End Class