Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb.net dataset question

Posted on 2011-02-18
11
Medium Priority
?
500 Views
Last Modified: 2012-06-22
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
0
Comment
Question by:geedub1961
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 1

Author Comment

by:geedub1961
ID: 34931084
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
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34933688
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
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 34933690
Since you need Vb.Net code so use this converter:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35021924
Still around?
0
 
LVL 1

Author Comment

by:geedub1961
ID: 35041497
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
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 35043863
0
 
LVL 19

Accepted Solution

by:
Shahan Ayyub earned 2000 total points
ID: 35043881
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
 
LVL 1

Author Comment

by:geedub1961
ID: 35044326

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

gw
0
 
LVL 1

Author Comment

by:geedub1961
ID: 35044351
Ok - I got it is the table "customers" in my case
0
 
LVL 1

Author Comment

by:geedub1961
ID: 35044426
Thanks Shahan
0
 
LVL 1

Author Closing Comment

by:geedub1961
ID: 35044428
thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question