PowerPoint Presentation (ADOworkwith)

 

DonorFind

 

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 connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

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

        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

 

    Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click

        Dim searchIndx As Integer

        Dim toFindName As String

        Dim foundName As Boolean = False

        toFindName = InputBox("Enter name you are searching for", "Search")

        Do While searchIndx < donorDT.Rows.Count And foundName = False

            If CStr(donorDT.Rows(searchIndx)("DName")) = toFindName Then

                foundName = True

                rowIndx = searchIndx

            Else

                searchIndx = searchIndx + 1

            End If

        Loop

        If foundName = True Then

            FillTextBoxes()

        Else

            txtDIdno.Text = ""

            txtDName.Text = "Name Not Found"

        End If

    End Sub

End Class

 

Bindonclick Project

 

Public Class frmBindonClick

    Inherits System.Windows.Forms.Form

    Dim rowIndx As Integer

    Dim donorDT As New DataTable

 

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

        If rowIndx < donorDT.Rows.Count - 1 Then

            rowIndx = rowIndx + 1

            FillTextBoxes()

        Else

            rowIndx = 0

            FillTextBoxes()

        End If

    End Sub

 

    Sub FillTextBoxes()

        txtDIdno.Text = CStr(donorDT.Rows(rowIndx)("DIdno"))

        txtDName.Text = CStr(donorDT.Rows(rowIndx)("DName"))

    End Sub

 

    Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click

        dataAdapter.Fill(donorDT)

        FillTextBoxes()

    End Sub

End Class

 

Module modLoad

    Public connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

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

    Public sqlStr As String = "Select * from Donor2000"

    Public dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)

End Module

 

DonorFormSQL 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 DIdno, DName from Donor2000 where DIdno > " & _

                 "'22222'"

        'Dim sqlStr As String = "Select DIdno, DZip from Donor2000 where DZip > " & _

        '          "'02700'"

        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

 

SQLdiff Project

 

Public Class frmDiffSQL

    Inherits System.Windows.Forms.Form

    Dim currMang As CurrencyManager

 

    Private Sub btnAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAll.Click

        DsStudent1.Clear()

        DaAll.Fill(DsStudent1)

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

    End Sub

 

    Private Sub btnCI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCI.Click

        DsStudent1.Clear()

        DaCI.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 += 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 btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click

        currMang.Position = currMang.Count - 1

    End Sub

End Class

 

SQLdiffcode Project

 

Public Class frmSQLdiff

    Inherits System.Windows.Forms.Form

    Dim stuDT As New DataTable

    Dim rowIndx As Integer

 

    Private Sub btnAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAll.Click

        Dim currpath As String = System.Environment.CurrentDirectory

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

                    "Data Source = " & currpath & "\stu2000.mdb"

        Dim sqlStr As String = "Select * from tablestu"

        Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)

        stuDT.Clear()

        dataAdapter.Fill(stuDT)

        FillTextBoxes()

    End Sub

    Sub FillTextBoxes()

        txtIdno.Text = CStr(stuDT.Rows(rowIndx)("Idno"))

        txtName.Text = CStr(stuDT.Rows(rowIndx)("Name"))

        txtMajor.Text = CStr(stuDT.Rows(rowIndx)("Major"))

    End Sub

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

        If rowIndx < stuDT.Rows.Count - 1 Then

            rowIndx = rowIndx + 1

            FillTextBoxes()

        Else

            rowIndx = 0

            FillTextBoxes()

 

        End If

    End Sub

 

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

        rowIndx = 0

        FillTextBoxes()

    End Sub

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

        rowIndx = stuDT.Rows.Count - 1

        FillTextBoxes()

    End Sub

 

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

        If rowIndx > 0 Then

            rowIndx = rowIndx - 1

            FillTextBoxes()

        Else

            rowIndx = 0

            FillTextBoxes()

        End If

    End Sub

 

    Private Sub btnCI_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCI.Click

        Dim currpath As String = System.Environment.CurrentDirectory

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

                    "Data Source = " & currpath & "\stu2000.mdb"

        Dim sqlStr As String = "Select * from tablestu where major = " & _

               "'CI'"

        Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)

        stuDT.Clear()

        dataAdapter.Fill(stuDT)

        FillTextBoxes()

    End Sub

End Class

 

Donortwotables Project

 

Public Class frmTwoTables

    Inherits System.Windows.Forms.Form

    Dim conDonorDB As String

    Dim donorDS As New DataSet

    Dim sqlDonor As String

    Dim sqlDonation As String

    Dim sqlMatchDonation As String

    Dim rowIndx As Integer

 

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

        conDonorDB = "Provider=Microsoft.Jet.OLEDB.4.0;" & _

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

        sqlDonor = "Select DIdno, DName from Donor2000"

        sqlDonation = "Select DIdno, DDriveNo, DDateCont, DAmtCont from Donation2000 order by DIdno"

        Dim daDonor As New OleDb.OleDbDataAdapter(sqlDonor, conDonorDB)

        Dim daDonation As New OleDb.OleDbDataAdapter(sqlDonation, conDonorDB)

        daDonor.Fill(donorDS, "Donor2000")

        daDonation.Fill(donorDS, "Donation2000")

        FillTextBoxes()

        dgdDonation.DataSource = donorDS.Tables(1)

        daDonor.Dispose()

        daDonation.Dispose()

    End Sub

    Sub FillTextBoxes()

        txtDIdno.Text = CStr(donorDS.Tables(0).Rows(rowIndx)("DIdno"))

        txtDName.Text = CStr(donorDS.Tables(0).Rows(rowIndx)("DName"))

 

    End Sub

 

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

        If rowIndx < donorDS.Tables(0).Rows.Count - 1 Then

            rowIndx = rowIndx + 1

            FillTextBoxes()

        Else

            rowIndx = 0

            FillTextBoxes()

        End If

    End Sub

 

    Private Sub btnMatch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMatch.Click

        Dim RowFilter As String = "DIdno = '" & txtDIdno.Text & "'"

        Dim dvDonation As DataView = New DataView(donorDS.Tables("Donation2000"), _

                               RowFilter, "DIdno", DataViewRowState.CurrentRows)

        dgdDonation.DataSource = dvDonation

    End Sub

 

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

        If rowIndx = 0 Then

            FillTextBoxes()

        Else

            rowIndx = rowIndx - 1

            FillTextBoxes()

        End If

    End Sub

End Class