Delete,Insert,Update Through Binding Navigator

Joined
Sep 2, 2012
Messages
14
Programming Experience
Beginner
Hi Experts,

Im Using Binding Navigator control in my form.Im doing navigation in that and its working fine but when i delete the record with that then its not deleting from the database

so i want to know how to insert, update,delete to the database using binding navigator

Any Help Would be greatly appreciated


Thanks

Shafi
 
Hi,

You need to provide a bit more information for us to help you better since if you have created your binding navigator from the VS IDE by dragging a data object from the Data Sources tab then this should all be done for you. So questions are:-

1) Do you get an error when trying to delete using the binding navigator? If so, what is the error reported. (if you are then it is probably a primary key issue with the data source)

2) If you have created the BindingNavigator by dragging it from the tool box what properties have you set?

Hope that helps.

Cheers,

Ian
 
Thanks for ur reply Ian

Its working fine . im not getting any errors but when i click on deletebutton it is deleting in the form but when i go to database and see then those values are not deleted it is still there in database
In the same way i want the save button and update button code
 
Hi,

OK, so did you create all these controls in the VS IDE (therefore all properties should have been set correctly for you by the IDE) or have you set up these controls and their properties within your code? If you have done this in code then please post the relevant code that sets up the controls and their data bindings so that we can see if you have missed something and advise if you need to create your own Update / Delete and Insert commands.

Hope that helps.

Cheers,

Ian
 
Thanks Again for ur reply Ian,

I have two textboxes on my form lets say userid and username and I also used the Binding Navigator control from the toolbox(Drag and drop) After this i used binding source control(Drag and drop) and i attached tables to the binding source. After this i attached binding source to the binding navigator .
After this step i have done the databinding to the text boxes.After this step i ran my program by pressing F5 button
Then I used Navigation buttons it worked fine for me
but when i use the delete button then it seems that records are deleting but when i go and check in the database i saw that the records are not deleted . (I think It is only deleting records from dataset not from database if this is the case now i want to know how to reflect that dataset records to my database)
The same thing i want to do for insert and update records

Thanks
Shafi
 
Hi,

The one object which you are missing to allow modification of your database is a TableAdapter but since I cannot see exactly how you have done things I cannot give you an exact answer.

If you are making a simple data entry form then the best way to do this is from the Visual Studio IDE. If you follow these simple steps the IDE will create everything for you to interact with your backend database:-

1) Create a new Form and then open the Data Sources Tab, Data->Show Data Sources. If you have not already added your Data Source, click on Add New Data Source and follow the simple steps in the Wizard to create a Database and a Dataset.

2) Once created click the arrow to the left of your DataSet in the Data Sources window to display your Table names

3) Click the arrow to the left of the Table name you want to work with to show the field names in the table

4) Click on the Field Name that you want to add to the form and dropdown the combobox arrow to the right of the field name and then select the type of control you want to place on the form for each field. Let's say TextBox for now.

5) Lastly, drag the field name onto the Form.

When the first field is dragged onto the form the IDE automatically adds a Dataset, a BindingSource, a TableAdapter, a TableAdapterManager and a BindingNavigator to the form and creates all the necessary code for you to interact with your database without writing a single line of code.

Hope that helps.

Cheers,

Ian
 
Just to make sure, did you press SAVE after deleting the row? If you did, please double click on the 'Save' icon and see if there is any code in there.
The code should be:

         Me.Validate()
    Me.BINDINGSOURCENAME.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DATASETNAME)

As IanRyder said, make sure that you have all of the required components.
You should have those components: Dataset, BindingSource, BindingNavigator, TableAdapter and a TableAdapterManager. Those components can be found in the ToolBox, or generated automatically once you are dragging a DataGridView or Detail View on your form.
 
Back
Top