vb.net dataset question

I am a novice with vb.net  - I have used access alot but very little experience in vb.net.

I built a simple form that has two fields and is connected via dataset.

I need help understanding how to update from  the dataset back to the table from where it came from.
 

THIS IS THE CODE
Public Class Form1

    Private Sub CustomersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomersBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.CustomersBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.NwindDataSet)

    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 'NwindDataSet.Customers' table. You can move, or remove it, as needed.
        Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)

    End Sub

    Private Sub BindingNavigatorAddNewItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorAddNewItem.Click

    End Sub
End Class
LVL 1
geedub1961Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Shahan AyyubConnect With a Mentor Senior Software Engineer - iOSCommented:
Also,

        Try
            Me.Validate()
            Me.TblStdBindingSource.EndEdit()
            Db2DataSet.tblStd.AcceptChanges()
            Me.TblStdTableAdapter.Update(Db2DataSet.tblStd)
        Catch ex As Exception
            MsgBox("Update failed")
        End Try

Open in new window

0
 
geedub1961Author Commented:
As of now I am able to get the data on the form in the text boxes - I just can not figure out how to save the data back to the table.

Thanks for any help on this.
0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
Hi!

check your code by doing it this way:
http://forums.asp.net/p/1390628/2978412.aspx

Also, check it by using AcceptChanges() method of DataSet.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Shahan AyyubSenior Software Engineer - iOSCommented:
Since you need Vb.Net code so use this converter:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
 
CodeCruiserCommented:
Still around?
0
 
geedub1961Author Commented:
Yes - I finally figured this out - at least to update the database.   For anyone else trying this it might be important to note that I needed to build the application before the update would actually work.

I am not able to add a record and have it saved yet.   Maybe I can get some help on that part.

Whenever I add a record i get "failed to update".

gw

Try
            Me.Validate()
            Me.CustomersBindingSource.EndEdit()
            Me.CustomersTableAdapter.Update(Me.NwindDataSet1.Customers)
            MsgBox("Update successful")

        Catch ex As Exception
            MsgBox("Update failed")
        End Try


0
 
Shahan AyyubSenior Software Engineer - iOSCommented:
0
 
geedub1961Author Commented:

Db2DataSet.tblStd.AcceptChanges()
What is the tblstd in the middle?  is that the same as my CustomersTableAdapter?

gw
0
 
geedub1961Author Commented:
Ok - I got it is the table "customers" in my case
0
 
geedub1961Author Commented:
Thanks Shahan
0
 
geedub1961Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.