ADO DOT NET
Well-known member
- Joined
- Dec 20, 2006
- Messages
- 156
Hi,
I have an Access database which has 2 tables named "Groups" and "Users".
The snap shot shows the contents of both!
I use this code to delete from Groups Table:
Thats OK and have no problem!
My problem is that:
As you see in the picture, in the Groups Table, each group has a unique ID which will be automatically assigned by the system.
When I add a user information to the Users Table, I copy that auto numbered ID from Groups table to Users Table under G-ID.
I want that when I run that code to delete a group all users assosicated with the same ID be deleted also (If Groups ID = Users G-ID)
Something like this:
I cannot figure this because I am new in ADO DOT NET!
Can you please help me?!
I have an Access database which has 2 tables named "Groups" and "Users".
The snap shot shows the contents of both!
I use this code to delete from Groups Table:
Code:
Dim DB As OleDb.OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + My.Application.Info.DirectoryPath + "\AccessDB.mdb;Jet OLEDB:Database Password = MyPassword")
DB.Open()
Dim DeleteGroup As New OleDb.OleDbCommand("DELETE FROM Groups WHERE GroupName = " + GroupTextBox.Text + "", DB)
DeleteGroup.ExecuteNonQuery()
DB.Close()
My problem is that:
As you see in the picture, in the Groups Table, each group has a unique ID which will be automatically assigned by the system.
When I add a user information to the Users Table, I copy that auto numbered ID from Groups table to Users Table under G-ID.
I want that when I run that code to delete a group all users assosicated with the same ID be deleted also (If Groups ID = Users G-ID)
Something like this:
Code:
Dim DB As OleDb.OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + My.Application.Info.DirectoryPath + "\AccessDB.mdb;Jet OLEDB:Database Password = MyPassword")
DB.Open()
Dim DeleteGroup As New OleDb.OleDbCommand("DELETE FROM Groups WHERE GroupName = " + GroupTextBox.Text + "", DB)
DeleteGroup.ExecuteNonQuery()
Dim DeleteRecipient As New OleDb.OleDbCommand("DELETE FROM Users WHERE G-ID = " + GroupID + "", DB)
DeleteRecipient.ExecuteNonQuery()
DB.Close()
I cannot figure this because I am new in ADO DOT NET!
Can you please help me?!