Deletting records from two tables

sadimul
sadimul used Ask the Experts™
on
I am trying to delete records from 2 tables using the dataset and trying to update the access data base. I am getting error when I tried to update the 2nd table. Here is the source...


Dim conn As New OleDb.OleDbConnection
        conn.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;data source=C:\Ca_SwTst.mdb"
        conn.Open()
        Dim Ds As New DataSet
        Dim dt As New DataTable
        dt.TableName = "Samp1"
        Ds.Tables.Add(dt)
        Dim da As OleDbDataAdapter
        da = New OleDbDataAdapter("select * from emails", conn)
        Dim cb1 As New OleDbCommandBuilder(da)
        da.Fill(dt)
        dt = New DataTable
        dt.TableName = "sample2"
        Ds.Tables.Add(dt)
        da = New OleDbDataAdapter("select * from Cashier", conn)
        da.Fill(dt)
        Dim cb As New OleDbCommandBuilder(da)
        For Each dr As DataRow In Ds.Tables("Samp1").Rows

            dr.Delete()
        Next
        For Each dr As DataRow In Ds.Tables("sample2").Rows

            dr.Delete()
        Next
        da.Update(Ds, "sample2")
        da.Update(Ds, "Samp1")
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2008

Commented:
What is the exception that you are getting?
Commented:
I resolved it by updating the table "sample1" with the data adapter before I reteive the data from the 2nd table.

Author

Commented:
resolved it by updating the table "sample1" with the data adapter before I reteive the data from the 2nd table.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial