|
-
May 13th, 2008, 02:31 AM
#1
Thread Starter
Hyperactive Member
delete record from 2 tables
INstead of this, any better way to delete record from 2 tables in a faster way?
m_con = New SQLiteConnection(ConfigurationManager.ConnectionStrings("constr").ToString)
m_con.Open()
m_sqlstate = "" : m_sqlstate = "SELECT * FROM cust_userdetails"
m_da = New SQLiteDataAdapter(m_sqlstate, m_con)
m_cmdbuilder = New SQLiteCommandBuilder(m_da)
m_ds = New DataSet
m_da.Fill(m_ds)
m_ds.Tables(0).PrimaryKey = New DataColumn() {m_ds.Tables(0).Columns("member_id")}
m_dr = m_ds.Tables(0).Rows.Find(m_memberid)
If m_dr IsNot Nothing Then m_dr.Delete()
m_da.Update(m_ds)
m_sqlstate = "" : m_sqlstate = "SELECT * FROM cust_license"
m_da = New SQLiteDataAdapter(m_sqlstate, m_con)
m_cmdbuilder = New SQLiteCommandBuilder(m_da)
m_ds = New DataSet
m_da.Fill(m_ds)
m_ds.Tables(0).PrimaryKey = New DataColumn() {m_ds.Tables(0).Columns("member_id")}
m_ds.Tables(0).PrimaryKey = New DataColumn() {m_ds.Tables(0).Columns("member_id")}
m_dr = m_ds.Tables(0).Rows.Find(m_memberid)
If m_dr IsNot Nothing Then m_dr.Delete()
m_da.Update(m_ds)
-
May 13th, 2008, 06:23 AM
#2
Re: delete record from 2 tables
You can write a stored procedure to delete all records from child table and then delete records from master table.
-
May 13th, 2008, 02:37 PM
#3
Re: delete record from 2 tables
Run an ExecuteNonQuery against the tables
DELETE FROM Tablename
(This is assuming you want to delete all records in the tables, which is what it seems like you're doing)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|