Results 1 to 3 of 3

Thread: [2.0] Update Sql Database

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683

    [2.0] Update Sql Database

    I have a form and on the form are basically a bunch of textboxes. I dropped a sqldataadapter on the form and connected to my data. It created a binding source and my controls are all bound to it. When I start the form I get my first record and I can navigate throughout the database. When I make a change, it is stored in my dataset but that does not update the sql server. When I close the form and reopen, all my changes are gone. Where should I be updating the database (as I navigate, each record or when closing the form), and how?

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    683

    Re: [2.0] Update Sql Database

    WOW, I found it and it was fairly simple. I just added this on form closing. but is this the normal way to do it? ds7281 is my dataset.

    CODE] string strAnswer;
    strAnswer = Convert.ToString(MessageBox.Show("Do you wish to save your changes?", "Save Changes", MessageBoxButtons.YesNo));
    if (strAnswer == "Yes")
    {
    sqlDataAdapter1.Update(ds7281);
    }[/CODE]

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] Update Sql Database

    That is exactly how it's supposed to be done and is exactly what a DataAdapter is for.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width