hi i am having problem in deleting a single row from a gridview. i am using binding navigaator to delete the row. i have customer table and booking table. Cust_id is used as foreign key in booking table. when i try to delete a single row from booking table it delete all the bookings related to that customer in the gridview.It also deletes the related customer aswell. i just want to delete one booking of that customer
Me.Validate()
Me.CustomerBindingSource.EndEdit()
Me.CustomerTableAdapter.Update(NewBookingDataSet.Customer)
Me.BookingBindingSource.EndEdit()
Me.BookingTableAdapter.Update(NewBookingDataSet.Booking)
if i use the above coding under a button than i get the following error but if i use the same code under binding navigator save_item it works fine..here is the error which i get when used under buttonThe INSERT statement conflicted with the FOREIGN KEY constraint "FK_Booking_Customer". The conflict occurred in database "photoshoot", table "dbo.Customer", column 'Cust_id'.
The statement has been terminated.
ur booking table must be having a primary key right?? guess booking_id
one thing u can do is...
take a text box and make it visibility as false
when the user will click on the datagrid the booking id shud be inserted in the textbox and then on the delete button add the code to delete the booking id as it is in the text box....
'code to get the bookingid from datagrid
'code should be wriiten in the cell click event of datagrid
Dim i As Integer
i = datagridView1.CurrentRow.Index
textbox1.text= datagridView1.Item(0, …