Code from projects explained in ADOfirstcont PowerPoint (not the first project in that presentation is on the ADOfirst listing)
DonorFormCodeSO Project
Public Class
frmDonorCode
Inherits
System.Windows.Forms.Form
Dim donorDT As New DataTable
Dim
rowIndx As Integer
Private Sub frmDonorCode_Load(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
Dim currpath As String =
System.Environment.CurrentDirectory
Dim connStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = " & currpath &
"\donor.mdb"
MsgBox(currpath)
MsgBox(connStr)
Dim sqlStr As String =
"Select * from Donor2000"
Dim dataAdapter As New
OleDb.OleDbDataAdapter(sqlStr, connStr)
dataAdapter.Fill(donorDT)
dataAdapter.Dispose()
FillTextBoxes()
End Sub
Sub FillTextBoxes()
txtDIdno.Text = CStr(donorDT.Rows(rowIndx)("DIdno"))
txtDName.Text = CStr(donorDT.Rows(rowIndx)("DName"))
End
Sub
Private Sub btnReadNext_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnReadNext.Click
If rowIndx <
donorDT.Rows.Count - 1 Then
rowIndx = rowIndx + 1
FillTextBoxes()
Else
rowIndx = 0
FillTextBoxes()
End If
End Sub
End Class
Public Class
frmDonorCode
Inherits
System.Windows.Forms.Form
Dim donorDT As New DataTable
Dim rowIndx As Integer
Private Sub frmDonorCode_Load(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
Dim currpath As String =
System.Environment.CurrentDirectory
Dim connStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = " & currpath &
"\donor.mdb"
'MsgBox(currpath)
'MsgBox(connStr)
Dim sqlStr As String =
"Select DIdno, DName from Donor2000 where DIdno > " & _
"'22222'"
MsgBox(sqlStr)
Dim dataAdapter As New
OleDb.OleDbDataAdapter(sqlStr, connStr)
dataAdapter.Fill(donorDT)
dataAdapter.Dispose()
FillTextBoxes()
End Sub
Sub FillTextBoxes()
txtDIdno.Text = CStr(donorDT.Rows(rowIndx)("DIdno"))
txtDName.Text = CStr(donorDT.Rows(rowIndx)("DName"))
End Sub
Private Sub btnReadNext_Click(ByVal sender
As System.Object, ByVal
e As System.EventArgs) Handles
btnReadNext.Click
If rowIndx <
donorDT.Rows.Count - 1 Then
rowIndx = rowIndx + 1
FillTextBoxes()
Else
rowIndx = 0
FillTextBoxes()
End If
End Sub
End Class
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
OleDbAdaptablestu.Fill(DataSetStudent1)
End Sub
End Class
Public Class
frmGridCode
Inherits
System.Windows.Forms.Form
Dim stuDT As New DataTable
Private Sub frmGridCode_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles
MyBase.Load
'Specifies the source of the
access database by address
'Dim connStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
' "Data
Source = C:\VBNETCIS56\ADO\stu2000.mdb"
Dim currpath As String =
System.Environment.CurrentDirectory
Dim connStr As String =
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = " & currpath &
"\stu2000.mdb"
MsgBox(currpath)
MsgBox(connStr)
Dim sqlStr As String =
"Select * from tablestu Order By idno"
Dim DataAdapter As New
OleDb.OleDbDataAdapter(sqlStr, connStr)
DataAdapter.Fill(stuDT)
dgdStu.DataSource = stuDT
End Sub
End Class