moman1981's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
Members
Active Posts:
43 (0.03 per day)
Joined:
17-December 09
Profile Views:
1,244
Last Active:
User is offline Nov 02 2011 05:29 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0

Latest Visitors

Icon   moman1981 has not set their status

Posts I've Made

  1. In Topic: ERROR while trying to update Access database with OleDbCommandBuilder

    Posted 8 Oct 2011

    Thank you for all your help. I am at least able to update the dataset and that is a step further than what I was a couple of hours ago.

    Thank you.
  2. In Topic: ERROR while trying to update Access database with OleDbCommandBuilder

    Posted 8 Oct 2011

    If I remove the "da.AcceptChanges()" statement, then I get the same error that started this mess.
  3. In Topic: ERROR while trying to update Access database with OleDbCommandBuilder

    Posted 8 Oct 2011

    UPDATED CODE

    
    Imports System.Data.OleDb
    
    Public Class AssignedPersonnel
        Dim inc As Integer
        Dim MaxRows As Integer
        Dim con As New OleDb.OleDbConnection
        Dim dbProvider As String
        Dim dbSource As String
        Dim ds As New DataSet
        Dim da As New OleDb.OleDbDataAdapter
        Dim sql As String
    
        Private Sub btnMainMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMainMenu.Click
            Me.Hide()
            'MaintainPersonnel.Show()
        End Sub
    
       
    
        Private Sub AssignedPersonnel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
            dbSource = "Data Source = C:\Users\Lucas\Documents\VisualBasic\CSGLP_3\CSCSU GL Personnel 2011.accdb"
    
           
            con.ConnectionString = dbProvider & dbSource
    
            Try
                con.Open()
    
                sql = "SELECT * FROM AssignedPersonnel" ' order by LASTNAME asc"
                da = New OleDb.OleDbDataAdapter(sql, con)
                da.Fill(ds, "CSGLPAP")
    
                
            Catch ex As Exception
                MsgBox(ex.Message.ToString)
            End Try
    
            con.Close()
            
            MaxRows = ds.Tables("CSGLPAP").Rows.Count
    
            inc = -1
    
    
            txtMaxRows.Text = MaxRows.ToString
        End Sub
    
        Private Sub NavigateRecords()
            '=====================ASSIGNED PERSONNEL, MEMBER INFORMATION=======================
            txtLast4.Text = ds.Tables("CSGLPAP").Rows(inc).Item(2).ToString()
            txtTitle.Text = ds.Tables("CSGLPAP").Rows(inc).Item(7).ToString()
            txtPayGrade.Text = ds.Tables("CSGLPAP").Rows(inc).Item(8).ToString()
            txtLname.Text = ds.Tables("CSGLPAP").Rows(inc).Item(3).ToString()
            txtFname.Text = ds.Tables("CSGLPAP").Rows(inc).Item(4).ToString()
            txtMinitial.Text = ds.Tables("CSGLPAP").Rows(inc).Item(5).ToString()
            txtGender.Text = ds.Tables("CSGLPAP").Rows(inc).Item(9).ToString()
    
    
        End Sub
    
        Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
            Dim cb As New OleDb.OleDbCommandBuilder(da)
    
            If inc = -1 Then
                MsgBox("No Records Yet")
            ElseIf inc <> -1 Then
                '=====================DATA UPDATES=======================
                '=====================ASSIGNED PERSONNEL, MEMBER INFORMATION=======================
                ds.Tables("CSGLPAP").Rows(inc).Item(2) = txtLast4.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(7) = txtTitle.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(8) = txtPayGrade.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(3) = txtLname.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(4) = txtFname.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(5) = txtMinitial.Text
                ds.Tables("CSGLPAP").Rows(inc).Item(9) = txtGender.Text
    
                '=====================PUSH TO DATABASE =======================
                Try
                    ds.AcceptChanges() 'accept changes made to it
                    Dim change As DataSet = ds.GetChanges() 'get all changes
                    Dim commandbuild As New OleDbCommandBuilder(da) 'command builder
                    If change IsNot Nothing Then 'if there is any change
                        da.Update(change, "CSGLPAP") 'update
                    End If
    
                    MsgBox("Data updated")
                Catch ex As Exception
                    MsgBox(ex.Message.ToString)
                End Try
            End If
        End Sub
    End Class
    
    
    
    
    
  4. In Topic: ERROR while trying to update Access database with OleDbCommandBuilder

    Posted 8 Oct 2011

    yes, the data is not being saved in the database. it looks like it is only being saved in the data set and when the program i closed and then re-opened, the original data is still there. So the data is not getting from the data set to the linked database.
  5. In Topic: ERROR while trying to update Access database with OleDbCommandBuilder

    Posted 8 Oct 2011

    smohd,

    Thank you. That seemed to work to update the DataSet, but when I close the program and re-run it, the changes are not there.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

Comments

moman1981 has no profile comments yet. Why not say hello?