Solved

update edit and delete the data fro

Posted on 2007-04-10
4
251 Views
Last Modified: 2013-11-26
Hello

This is my first vb.net program which display, add, update and edit data from a tblEmployees (table).
The display part is working fine, I need help in update, add and delete the database.
I copy the code from a book I know the I don't know where to put the following code

   Private Sub EditState(ByVal pblnState As Boolean)
        Select Case pblnState
            Case cblnEditing
                Button5.Enabled = False
                Button6.Enabled = False
                Button7.Enabled = True
                Button8.Enabled = False
                'Code to enable all text boxes.
            Case cblnNotEditing
                Button5.Enabled = True
                Button6.Enabled = True
                Button7.Enabled = False
                Button8.Enabled = False
                Button9.Enabled = True
                'Code to disable all text boxes.



        End Select
    End Sub

To Adding Updating a Record, i have to add the following code but I don't know where to put the following code

Dim pdsChangedRows As System.DataSet
pdsChangedRows = DsEmployees1.GetChanges()
odbaEmployees.Update(pdsChangedRows)
DsEmployees1.AcceptChanges()



Here is the code for all my program

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents odbconEmployees As System.Data.OleDb.OleDbConnection
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents Label5 As System.Windows.Forms.Label
    Friend WithEvents Label6 As System.Windows.Forms.Label
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents Label8 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents Button6 As System.Windows.Forms.Button
    Friend WithEvents Button9 As System.Windows.Forms.Button
    Friend WithEvents odbdaEmployees As System.Data.OleDb.OleDbDataAdapter
    Friend WithEvents OleDbSelectCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbInsertCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbUpdateCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents OleDbDeleteCommand1 As System.Data.OleDb.OleDbCommand
    Friend WithEvents DsEmployees1 As Startup06.dsEmployees
    Friend WithEvents txtEmployeedID As System.Windows.Forms.TextBox
    Friend WithEvents txtFirstName As System.Windows.Forms.TextBox
    Friend WithEvents txtLastName As System.Windows.Forms.TextBox
    Friend WithEvents txtHomePhone As System.Windows.Forms.TextBox
    Friend WithEvents txtHireDate As System.Windows.Forms.TextBox
    Friend WithEvents txtNotes As System.Windows.Forms.TextBox
    Friend WithEvents txtCity As System.Windows.Forms.TextBox
    Friend WithEvents txtCountry As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.odbconEmployees = New System.Data.OleDb.OleDbConnection
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.Label7 = New System.Windows.Forms.Label
        Me.Label8 = New System.Windows.Forms.Label
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button5 = New System.Windows.Forms.Button
        Me.Button6 = New System.Windows.Forms.Button
        Me.Button9 = New System.Windows.Forms.Button
        Me.txtEmployeedID = New System.Windows.Forms.TextBox
        Me.txtFirstName = New System.Windows.Forms.TextBox
        Me.txtLastName = New System.Windows.Forms.TextBox
        Me.txtHomePhone = New System.Windows.Forms.TextBox
        Me.txtHireDate = New System.Windows.Forms.TextBox
        Me.txtCity = New System.Windows.Forms.TextBox
        Me.txtCountry = New System.Windows.Forms.TextBox
        Me.txtNotes = New System.Windows.Forms.TextBox
        Me.odbdaEmployees = New System.Data.OleDb.OleDbDataAdapter
        Me.OleDbDeleteCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbInsertCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbSelectCommand1 = New System.Data.OleDb.OleDbCommand
        Me.OleDbUpdateCommand1 = New System.Data.OleDb.OleDbCommand
        Me.DsEmployees1 = New Startup06.dsEmployees
        CType(Me.DsEmployees1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'odbconEmployees
        '
        Me.odbconEmployees.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
        "ocking Mode=1;Data Source=""C:\Documents and Settings\Administrator\Desktop\Emplo" & _
        "yees.mdb"";Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.O" & _
        "LEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=F" & _
        "alse;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLE" & _
        "DB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't" & _
        " Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1" & _
        ""
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(56, 8)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Employee ID:"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(64, 48)
        Me.Label2.Name = "Label2"
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "First Name:"
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(72, 80)
        Me.Label3.Name = "Label3"
        Me.Label3.TabIndex = 2
        Me.Label3.Text = "Last Name:"
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(40, 112)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(120, 23)
        Me.Label4.TabIndex = 3
        Me.Label4.Text = "Telephone Number:"
        '
        'Label5
        '
        Me.Label5.Location = New System.Drawing.Point(80, 144)
        Me.Label5.Name = "Label5"
        Me.Label5.TabIndex = 4
        Me.Label5.Text = "Date Hired:"
        '
        'Label6
        '
        Me.Label6.Location = New System.Drawing.Point(80, 176)
        Me.Label6.Name = "Label6"
        Me.Label6.TabIndex = 5
        Me.Label6.Text = "City"
        '
        'Label7
        '
        Me.Label7.Location = New System.Drawing.Point(80, 216)
        Me.Label7.Name = "Label7"
        Me.Label7.TabIndex = 6
        Me.Label7.Text = "Country"
        '
        'Label8
        '
        Me.Label8.Location = New System.Drawing.Point(32, 264)
        Me.Label8.Name = "Label8"
        Me.Label8.TabIndex = 7
        Me.Label8.Text = "Notes"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(440, 16)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(104, 23)
        Me.Button1.TabIndex = 9
        Me.Button1.Text = "Navigatge First"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(448, 64)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(104, 23)
        Me.Button2.TabIndex = 10
        Me.Button2.Text = "Navigate Previous"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(456, 96)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(104, 23)
        Me.Button3.TabIndex = 11
        Me.Button3.Text = "Navigate Next"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(456, 128)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(104, 23)
        Me.Button4.TabIndex = 12
        Me.Button4.Text = "Navigate Last"
        '
        'Button5
        '
        Me.Button5.Location = New System.Drawing.Point(456, 168)
        Me.Button5.Name = "Button5"
        Me.Button5.Size = New System.Drawing.Size(96, 23)
        Me.Button5.TabIndex = 13
        Me.Button5.Text = "Add"
        '
        'Button6
        '
        Me.Button6.Location = New System.Drawing.Point(448, 208)
        Me.Button6.Name = "Button6"
        Me.Button6.Size = New System.Drawing.Size(112, 23)
        Me.Button6.TabIndex = 14
        Me.Button6.Text = "Edit"
        '
        'Button9
        '
        Me.Button9.Location = New System.Drawing.Point(464, 248)
        Me.Button9.Name = "Button9"
        Me.Button9.Size = New System.Drawing.Size(104, 23)
        Me.Button9.TabIndex = 17
        Me.Button9.Text = "Delete"
        '
        'txtEmployeedID
        '
        Me.txtEmployeedID.Location = New System.Drawing.Point(200, 8)
        Me.txtEmployeedID.Name = "txtEmployeedID"
        Me.txtEmployeedID.TabIndex = 19
        Me.txtEmployeedID.Text = ""
        '
        'txtFirstName
        '
        Me.txtFirstName.Location = New System.Drawing.Point(200, 48)
        Me.txtFirstName.Name = "txtFirstName"
        Me.txtFirstName.TabIndex = 20
        Me.txtFirstName.Text = ""
        '
        'txtLastName
        '
        Me.txtLastName.Location = New System.Drawing.Point(200, 80)
        Me.txtLastName.Name = "txtLastName"
        Me.txtLastName.TabIndex = 21
        Me.txtLastName.Text = ""
        '
        'txtHomePhone
        '
        Me.txtHomePhone.Location = New System.Drawing.Point(200, 104)
        Me.txtHomePhone.Name = "txtHomePhone"
        Me.txtHomePhone.TabIndex = 22
        Me.txtHomePhone.Text = ""
        '
        'txtHireDate
        '
        Me.txtHireDate.Location = New System.Drawing.Point(192, 144)
        Me.txtHireDate.Name = "txtHireDate"
        Me.txtHireDate.TabIndex = 23
        Me.txtHireDate.Text = ""
        '
        'txtCity
        '
        Me.txtCity.Location = New System.Drawing.Point(192, 176)
        Me.txtCity.Name = "txtCity"
        Me.txtCity.TabIndex = 24
        Me.txtCity.Text = ""
        '
        'txtCountry
        '
        Me.txtCountry.Location = New System.Drawing.Point(200, 208)
        Me.txtCountry.Name = "txtCountry"
        Me.txtCountry.TabIndex = 25
        Me.txtCountry.Text = ""
        '
        'txtNotes
        '
        Me.txtNotes.Location = New System.Drawing.Point(168, 248)
        Me.txtNotes.Multiline = True
        Me.txtNotes.Name = "txtNotes"
        Me.txtNotes.Size = New System.Drawing.Size(256, 56)
        Me.txtNotes.TabIndex = 26
        Me.txtNotes.Text = ""
        '
        'odbdaEmployees
        '
        Me.odbdaEmployees.DeleteCommand = Me.OleDbDeleteCommand1
        Me.odbdaEmployees.InsertCommand = Me.OleDbInsertCommand1
        Me.odbdaEmployees.SelectCommand = Me.OleDbSelectCommand1
        Me.odbdaEmployees.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "tblEmployees", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("fldAddress", "fldAddress"), New System.Data.Common.DataColumnMapping("fldBirthDate", "fldBirthDate"), New System.Data.Common.DataColumnMapping("fldCity", "fldCity"), New System.Data.Common.DataColumnMapping("fldCountry", "fldCountry"), New System.Data.Common.DataColumnMapping("fldEmployeeID", "fldEmployeeID"), New System.Data.Common.DataColumnMapping("fldExtension", "fldExtension"), New System.Data.Common.DataColumnMapping("fldFirstName", "fldFirstName"), New System.Data.Common.DataColumnMapping("fldHireDate", "fldHireDate"), New System.Data.Common.DataColumnMapping("fldHomePhone", "fldHomePhone"), New System.Data.Common.DataColumnMapping("fldLastName", "fldLastName"), New System.Data.Common.DataColumnMapping("fldNotes", "fldNotes"), New System.Data.Common.DataColumnMapping("fldPhoto", "fldPhoto"), New System.Data.Common.DataColumnMapping("fldPostalCode", "fldPostalCode"), New System.Data.Common.DataColumnMapping("fldRegion", "fldRegion"), New System.Data.Common.DataColumnMapping("fldReportsTo", "fldReportsTo"), New System.Data.Common.DataColumnMapping("fldTitle", "fldTitle"), New System.Data.Common.DataColumnMapping("fldTitleOfCourtesy", "fldTitleOfCourtesy")})})
        Me.odbdaEmployees.UpdateCommand = Me.OleDbUpdateCommand1
        '
        'OleDbDeleteCommand1
        '
        Me.OleDbDeleteCommand1.CommandText = "DELETE FROM tblEmployees WHERE (fldEmployeeID = ?) AND (fldAddress = ? OR ? IS NU" & _
        "LL AND fldAddress IS NULL) AND (fldBirthDate = ? OR ? IS NULL AND fldBirthDate I" & _
        "S NULL) AND (fldCity = ? OR ? IS NULL AND fldCity IS NULL) AND (fldCountry = ? O" & _
        "R ? IS NULL AND fldCountry IS NULL) AND (fldExtension = ? OR ? IS NULL AND fldEx" & _
        "tension IS NULL) AND (fldFirstName = ?) AND (fldHireDate = ? OR ? IS NULL AND fl" & _
        "dHireDate IS NULL) AND (fldHomePhone = ? OR ? IS NULL AND fldHomePhone IS NULL) " & _
        "AND (fldLastName = ?) AND (fldPostalCode = ? OR ? IS NULL AND fldPostalCode IS N" & _
        "ULL) AND (fldRegion = ? OR ? IS NULL AND fldRegion IS NULL) AND (fldReportsTo = " & _
        "? OR ? IS NULL AND fldReportsTo IS NULL) AND (fldTitle = ? OR ? IS NULL AND fldT" & _
        "itle IS NULL) AND (fldTitleOfCourtesy = ? OR ? IS NULL AND fldTitleOfCourtesy IS" & _
        " NULL)"
        Me.OleDbDeleteCommand1.Connection = Me.odbconEmployees
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldEmployeeID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldEmployeeID", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldAddress", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldAddress", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldAddress1", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldAddress", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldBirthDate", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldBirthDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldBirthDate1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldBirthDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCity", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCity", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCity1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCity", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCountry", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCountry", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCountry1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCountry", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldExtension", System.Data.OleDb.OleDbType.VarWChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldExtension", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldExtension1", System.Data.OleDb.OleDbType.VarWChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldExtension", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldFirstName", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldFirstName", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHireDate", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHireDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHireDate1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHireDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHomePhone", System.Data.OleDb.OleDbType.VarWChar, 24, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHomePhone", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHomePhone1", System.Data.OleDb.OleDbType.VarWChar, 24, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHomePhone", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldLastName", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldLastName", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPostalCode", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPostalCode", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPostalCode1", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPostalCode", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldRegion", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldRegion", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldRegion1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldRegion", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldReportsTo", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldReportsTo", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldReportsTo1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldReportsTo", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitle", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitle", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitle1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitle", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitleOfCourtesy", System.Data.OleDb.OleDbType.VarWChar, 25, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitleOfCourtesy", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbDeleteCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitleOfCourtesy1", System.Data.OleDb.OleDbType.VarWChar, 25, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitleOfCourtesy", System.Data.DataRowVersion.Original, Nothing))
        '
        'OleDbInsertCommand1
        '
        Me.OleDbInsertCommand1.CommandText = "INSERT INTO tblEmployees(fldAddress, fldBirthDate, fldCity, fldCountry, fldExtens" & _
        "ion, fldFirstName, fldHireDate, fldHomePhone, fldLastName, fldNotes, fldPhoto, f" & _
        "ldPostalCode, fldRegion, fldReportsTo, fldTitle, fldTitleOfCourtesy) VALUES (?, " & _
        "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
        Me.OleDbInsertCommand1.Connection = Me.odbconEmployees
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldAddress", System.Data.OleDb.OleDbType.VarWChar, 60, "fldAddress"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldBirthDate", System.Data.OleDb.OleDbType.DBDate, 0, "fldBirthDate"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCity", System.Data.OleDb.OleDbType.VarWChar, 15, "fldCity"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCountry", System.Data.OleDb.OleDbType.VarWChar, 15, "fldCountry"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldExtension", System.Data.OleDb.OleDbType.VarWChar, 4, "fldExtension"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldFirstName", System.Data.OleDb.OleDbType.VarWChar, 10, "fldFirstName"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldHireDate", System.Data.OleDb.OleDbType.DBDate, 0, "fldHireDate"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldHomePhone", System.Data.OleDb.OleDbType.VarWChar, 24, "fldHomePhone"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldLastName", System.Data.OleDb.OleDbType.VarWChar, 20, "fldLastName"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldNotes", System.Data.OleDb.OleDbType.VarWChar, 0, "fldNotes"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPhoto", System.Data.OleDb.OleDbType.VarBinary, 0, "fldPhoto"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPostalCode", System.Data.OleDb.OleDbType.VarWChar, 10, "fldPostalCode"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldRegion", System.Data.OleDb.OleDbType.VarWChar, 15, "fldRegion"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldReportsTo", System.Data.OleDb.OleDbType.Integer, 0, "fldReportsTo"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldTitle", System.Data.OleDb.OleDbType.VarWChar, 30, "fldTitle"))
        Me.OleDbInsertCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldTitleOfCourtesy", System.Data.OleDb.OleDbType.VarWChar, 25, "fldTitleOfCourtesy"))
        '
        'OleDbSelectCommand1
        '
        Me.OleDbSelectCommand1.CommandText = "SELECT fldAddress, fldBirthDate, fldCity, fldCountry, fldEmployeeID, fldExtension" & _
        ", fldFirstName, fldHireDate, fldHomePhone, fldLastName, fldNotes, fldPhoto, fldP" & _
        "ostalCode, fldRegion, fldReportsTo, fldTitle, fldTitleOfCourtesy FROM tblEmploye" & _
        "es ORDER BY fldLastName, fldFirstName"
        Me.OleDbSelectCommand1.Connection = Me.odbconEmployees
        '
        'OleDbUpdateCommand1
        '
        Me.OleDbUpdateCommand1.CommandText = "UPDATE tblEmployees SET fldAddress = ?, fldBirthDate = ?, fldCity = ?, fldCountry" & _
        " = ?, fldExtension = ?, fldFirstName = ?, fldHireDate = ?, fldHomePhone = ?, fld" & _
        "LastName = ?, fldNotes = ?, fldPhoto = ?, fldPostalCode = ?, fldRegion = ?, fldR" & _
        "eportsTo = ?, fldTitle = ?, fldTitleOfCourtesy = ? WHERE (fldEmployeeID = ?) AND" & _
        " (fldAddress = ? OR ? IS NULL AND fldAddress IS NULL) AND (fldBirthDate = ? OR ?" & _
        " IS NULL AND fldBirthDate IS NULL) AND (fldCity = ? OR ? IS NULL AND fldCity IS " & _
        "NULL) AND (fldCountry = ? OR ? IS NULL AND fldCountry IS NULL) AND (fldExtension" & _
        " = ? OR ? IS NULL AND fldExtension IS NULL) AND (fldFirstName = ?) AND (fldHireD" & _
        "ate = ? OR ? IS NULL AND fldHireDate IS NULL) AND (fldHomePhone = ? OR ? IS NULL" & _
        " AND fldHomePhone IS NULL) AND (fldLastName = ?) AND (fldPostalCode = ? OR ? IS " & _
        "NULL AND fldPostalCode IS NULL) AND (fldRegion = ? OR ? IS NULL AND fldRegion IS" & _
        " NULL) AND (fldReportsTo = ? OR ? IS NULL AND fldReportsTo IS NULL) AND (fldTitl" & _
        "e = ? OR ? IS NULL AND fldTitle IS NULL) AND (fldTitleOfCourtesy = ? OR ? IS NUL" & _
        "L AND fldTitleOfCourtesy IS NULL)"
        Me.OleDbUpdateCommand1.Connection = Me.odbconEmployees
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldAddress", System.Data.OleDb.OleDbType.VarWChar, 60, "fldAddress"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldBirthDate", System.Data.OleDb.OleDbType.DBDate, 0, "fldBirthDate"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCity", System.Data.OleDb.OleDbType.VarWChar, 15, "fldCity"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldCountry", System.Data.OleDb.OleDbType.VarWChar, 15, "fldCountry"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldExtension", System.Data.OleDb.OleDbType.VarWChar, 4, "fldExtension"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldFirstName", System.Data.OleDb.OleDbType.VarWChar, 10, "fldFirstName"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldHireDate", System.Data.OleDb.OleDbType.DBDate, 0, "fldHireDate"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldHomePhone", System.Data.OleDb.OleDbType.VarWChar, 24, "fldHomePhone"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldLastName", System.Data.OleDb.OleDbType.VarWChar, 20, "fldLastName"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldNotes", System.Data.OleDb.OleDbType.VarWChar, 0, "fldNotes"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPhoto", System.Data.OleDb.OleDbType.VarBinary, 0, "fldPhoto"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldPostalCode", System.Data.OleDb.OleDbType.VarWChar, 10, "fldPostalCode"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldRegion", System.Data.OleDb.OleDbType.VarWChar, 15, "fldRegion"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldReportsTo", System.Data.OleDb.OleDbType.Integer, 0, "fldReportsTo"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldTitle", System.Data.OleDb.OleDbType.VarWChar, 30, "fldTitle"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("fldTitleOfCourtesy", System.Data.OleDb.OleDbType.VarWChar, 25, "fldTitleOfCourtesy"))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldEmployeeID", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldEmployeeID", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldAddress", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldAddress", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldAddress1", System.Data.OleDb.OleDbType.VarWChar, 60, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldAddress", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldBirthDate", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldBirthDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldBirthDate1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldBirthDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCity", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCity", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCity1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCity", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCountry", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCountry", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldCountry1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldCountry", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldExtension", System.Data.OleDb.OleDbType.VarWChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldExtension", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldExtension1", System.Data.OleDb.OleDbType.VarWChar, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldExtension", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldFirstName", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldFirstName", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHireDate", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHireDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHireDate1", System.Data.OleDb.OleDbType.DBDate, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHireDate", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHomePhone", System.Data.OleDb.OleDbType.VarWChar, 24, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHomePhone", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldHomePhone1", System.Data.OleDb.OleDbType.VarWChar, 24, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldHomePhone", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldLastName", System.Data.OleDb.OleDbType.VarWChar, 20, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldLastName", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPostalCode", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPostalCode", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldPostalCode1", System.Data.OleDb.OleDbType.VarWChar, 10, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldPostalCode", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldRegion", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldRegion", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldRegion1", System.Data.OleDb.OleDbType.VarWChar, 15, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldRegion", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldReportsTo", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldReportsTo", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldReportsTo1", System.Data.OleDb.OleDbType.Integer, 0, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldReportsTo", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitle", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitle", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitle1", System.Data.OleDb.OleDbType.VarWChar, 30, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitle", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitleOfCourtesy", System.Data.OleDb.OleDbType.VarWChar, 25, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitleOfCourtesy", System.Data.DataRowVersion.Original, Nothing))
        Me.OleDbUpdateCommand1.Parameters.Add(New System.Data.OleDb.OleDbParameter("Original_fldTitleOfCourtesy1", System.Data.OleDb.OleDbType.VarWChar, 25, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "fldTitleOfCourtesy", System.Data.DataRowVersion.Original, Nothing))
        '
        'DsEmployees1
        '
        Me.DsEmployees1.DataSetName = "dsEmployees"
        Me.DsEmployees1.Locale = New System.Globalization.CultureInfo("en-US")
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(824, 318)
        Me.Controls.Add(Me.txtNotes)
        Me.Controls.Add(Me.txtCountry)
        Me.Controls.Add(Me.txtCity)
        Me.Controls.Add(Me.txtHireDate)
        Me.Controls.Add(Me.txtHomePhone)
        Me.Controls.Add(Me.txtLastName)
        Me.Controls.Add(Me.txtFirstName)
        Me.Controls.Add(Me.txtEmployeedID)
        Me.Controls.Add(Me.Button9)
        Me.Controls.Add(Me.Button6)
        Me.Controls.Add(Me.Button5)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label8)
        Me.Controls.Add(Me.Label7)
        Me.Controls.Add(Me.Label6)
        Me.Controls.Add(Me.Label5)
        Me.Controls.Add(Me.Label4)
        Me.Controls.Add(Me.Label3)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.DsEmployees1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub odbdaEmployees_RowUpdated(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbRowUpdatedEventArgs) Handles odbdaEmployees.RowUpdated

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       
        Dim pbndTemp As Binding
        Dim pintRecords As Integer
        pintRecords = odbdaEmployees.Fill(DsEmployees1)
        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldEmployeeID")
        txtEmployeedID.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldLastName")
        txtLastName.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldFirstName")
        txtFirstName.DataBindings.Add(pbndTemp)
        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldHomePhone")
        txtHomePhone.DataBindings.Add(pbndTemp)
        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldHireDate")
        txtHireDate.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldCity")
        txtCity.DataBindings.Add(pbndTemp)

        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldCountry")
        txtCountry.DataBindings.Add(pbndTemp)
       
        pbndTemp = New Binding("Text", DsEmployees1, "tblEmployees.fldNotes")
        txtNotes.DataBindings.Add(pbndTemp)



     

     
     

     




    End Sub
   

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.BindingContext(DsEmployees1, "tblEmployees").Position = 0
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.BindingContext(DsEmployees1, "tblEmployees").Position -= 1
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.BindingContext(DsEmployees1, "tblEmployees").Position += 1
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Me.BindingContext(DsEmployees1, "tblEmployees").Position = Me.DsEmployees1.tblEmployees.Rows.Count - 1
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim pdsChangedRows As DataSet
        Call EditState(cblnNotEditing)
        Me.BindingContext(dsEmployees, "tblEmployees").EndCurrentEdit()
        pdsChangedRows = dsEmployees.GetChanges()
        If Not pdsChangedRows Is Nothing Then
            odbaEmployees.Update(pdsChangedRows)
        End If
        DsEmployees1.AcceptChanges()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub EditState(ByVal pblnState As Boolean)
        Select Case pblnState
            Case cblnEditing
                Button5.Enabled = False
                Button6.Enabled = False
                Button7.Enabled = True
                Button8.Enabled = False
                'Code to enable all text boxes.
            Case cblnNotEditing
                Button5.Enabled = True
                Button6.Enabled = True
                Button7.Enabled = False
                Button8.Enabled = False
                Button9.Enabled = True
                'Code to disable all text boxes.



        End Select
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        Call EditState(cblnEditing)

        Me.BindingContext(DsEmployees1, "tblEmployees").AddNew()
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        Dim pdsDeletedRows As DataSet
        Me.BindingContext(DsEmployees1, "tblEmployees").RemoveAt(Me.BindingContext(DsEmployees1, "tblEmployees").Position)
        pdsDeletedRows = dsEmployees.GetChanges(DataRowState.Deleted)
        odbdaEmployees.Update(pdsDeleteRows)
        DsEmployees1.AcceptChanges()


    End Sub
End Class
0
Comment
Question by:sfareed
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
dmagliola earned 500 total points
ID: 18887340
Basically what you are doing with this code is loading the info from the database in a "form-level" dataset (shared by all methods in the form), and binding the controls to it. What the binding will do is not only showing the data in the form, but also copying any change you do in the controls to the actual data in the dataset. With this code:

Dim pdsChangedRows As System.DataSet
pdsChangedRows = DsEmployees1.GetChanges()
odbaEmployees.Update(pdsChangedRows)
DsEmployees1.AcceptChanges()

you take the changes and send them back to the DB.

What I would do is add an "Update" button that runs the code you mention in it's Click event, thus updating the database.
0
 

Author Comment

by:sfareed
ID: 18889283
Where should I add the following code --
********
Dim pdsChangedRows As System.DataSet
pdsChangedRows = DsEmployees1.GetChanges()
odbaEmployees.Update(pdsChangedRows)
DsEmployees1.AcceptChanges()
*******

I do have an update button should i double click the update button and add the code into private sub area?

0
 
LVL 3

Expert Comment

by:dmagliola
ID: 18890884
Yes
0
 

Author Comment

by:sfareed
ID: 18894087
I have a problem when I run you suggested code, I am getting the following error after i debug

Type 'System.DataSet' is not defined.

Name 'odbaEmployees' is not declared

Please help me

thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now