Link to home
Start Free TrialLog in
Avatar of sadimul
sadimul

asked on

Deletting records from two tables

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")
Avatar of BuggyCoder
BuggyCoder
Flag of India image

Avatar of Bob Learned
What is the exception that you are getting?
ASKER CERTIFIED SOLUTION
Avatar of sadimul
sadimul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sadimul
sadimul

ASKER

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