Guyzz My project is on Restaurant Mgm.
I stuck to a place,where I have to Delete Values from Multiple Tables in the database
This is My code
Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
Dim id1 As Integer
id1 = Cbid.SelectedItem
ds.Dispose()
con.ConnectionString = "Data Source=localhost;Integrated Security=true;Initial Catalog=Restaurant"
cmd.CommandText = "Select Table_id,Booking_id From Booking_Details Where Reservation_id=" & id1
cmd.Connection = con
da.SelectCommand = cmd
con.Open()
da.Fill(ds, "Cancel1")
con.Close()
da.Dispose()
Dim w As Integer
Dim x As Integer
Dim t As Integer
Dim b As Integer
w = ds.Tables("Cancel1").Rows.Count - 1
For x = 0 To w
b = ds.Tables("Cancel1").Rows.Item(x).Item("Booking_id")
t = ds.Tables("Cancel1").Rows.Item(x).Item("Table_id")
Dim n As String
n = "NO"
con.ConnectionString = "Data Source=localhost;Integrated Security=true;Initial Catalog=Restaurant"
cmd.CommandText = "Update Table_Details set Reserved='" & n & "'where Table_id=" & t
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
con.Dispose()
cmd.Dispose()
Next
con.ConnectionString = "Data Source=localhost;Integrated Security=true;Initial Catalog=Restaurant"
cmd.CommandText = "Delete from Reservation Where Reservation_id=" & id1
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
con.Dispose()
cmd.Dispose()
con.Dispose()
MessageBox.Show("RECORD DELETED SUCCESSFULLY")
con.ConnectionString = "Data Source=localhost;Integrated Security=true;Initial Catalog=Restaurant"
cmd.CommandText = "Delete from Booking_Details Where Table_id=" & b
cmd.Connection = con
con.Open()
cmd.ExecuteNonQuery()
con.Close()
con.Dispose()
cmd.Dispose()
con.Dispose()
Call clear()
End Sub
It is deleting values only from Reservation Table......
But I want To delete Values from BookingDetails Tables and TableDetails Table...