Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Binding Navigator Not Working

vb.net 2008
sql server express 2005 sp3

Did I miss something.
I just created a Data Source to my sql server express table
Created a form.
Dragged my datasource node code to the form.
The dataset and binding navigator toolbar  was created.

But the records are not deleting or adding to the sql server database ?
The only code I see behind the buttons is the save button. code ???

Did I miss a step somewhere...
I thought the code to saving a record , saving, was added automatically during design mode.


Thannks
fordraiders


 
Avatar of Deepak Lakkad
Deepak Lakkad
Flag of India image

Hi,

Probably following code will be there on you Code Behind file

    Private Sub BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.BindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DataSet)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'IGMS_MasterDataSet.IGMS_Company' table. You can move, or remove it, as needed.
        Me.TableAdapter.Fill(Me.DataSet.IGMS_Company)
    End Sub

Open in new window


If yes, you are not missing anything, but do you press Save button after Deleting Record?

If you don't click on Save after Deleting record, it will not delete record.

- Deepak Lakkad
To save, add and update data from local datasource to database need to code. The controls only update/add/delete data from local source (dataset, datatable).
Avatar of Fordraiders

ASKER

Patel,
OK.Where are examples of this to finish it out..from locasource to database ?
 Thanks
fordraiders
Add a messagebox and load which shows the Update and Delete commands of the adapter.

msgbox(tableadaptername.UpdateCommand.CommandText)

Do you have a primary key in the Select statement or the column list?
CodeCruiser, Thanks for replying.
I have a primary key..., I guess I was assuming it worked the same as MsAccess... It writes directly to the data table and saves....it sounds as if this is is what it is doing in sql server express.?

I added this ?:
' for adding a new record..
 Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        TblMainDataBindingSource.AddNew()
    End Sub

So would I use the bindingsource.. to do all the saving into sql express table.. ?

Thanks
fordraiders
I think you would use tableadaptor.updateall() function.
ASKER CERTIFIED SOLUTION
Avatar of Deepak Lakkad
Deepak Lakkad
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That was it Thanks !