[AccessD] VB.Net, trying to update some records in Access

Charlotte Foust cfoust at infostatsystems.com
Wed Dec 7 19:23:35 CST 2005


What do you want it to do and why are you using AcceptChanges?  That
removes the modified flag from the row.  And calling in update on the
adapter does tell it to write the updates back to the table.

Charlotte Foust


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of David McAfee
Sent: Wednesday, December 07, 2005 4:22 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] VB.Net, trying to update some records in Access


Does anyone see what I am missing? I am trying to update some rows in a
temporary Access database by changing any pipes ( | ) to apostrophes ( '
). It runs through the code just fine. It's like the dataset is writing
the updates back to the table.

        Dim strTemp As String
        Dim row As DataRow
        Dim ds As DataSet
        Dim da As OleDbDataAdapter
        Dim conn As OleDbConnection
        Dim mystr As String
        Dim Connstr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\MOMS_UPDATE\MOMS_UPDATE.MDB;Persist Security Info=False"
        Dim mySQL = "SELECT ItemNo, Desc1 FROM Itemmast WHERE Desc1 Like
" &
Chr(34) & "%|%" & Chr(34) & ";"
        Try
            conn = New OleDbConnection(Connstr)
            da = New OleDbDataAdapter(mySQL, conn)
            ds = New DataSet
            da.Fill(ds)

            For Each row In ds.Tables(0).Rows
                strTemp = ""
                strTemp = replacePipes(row.Item("Desc1"))
                row.BeginEdit()
                'row("Desc1") = replacePipes(row("Desc1"))
                row.Item("Desc1") = strTemp
                'row.EndEdit()
                row.AcceptChanges()

            Next

            'ds.AcceptChanges()
            da.Update(ds.Tables(0))


            MessageBox.Show("dONE")
        Catch ex As Exception
            MessageBox.Show("Error " & Err.Number & " : " &
ex.Message.ToString())
        End Try

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list