Results 1 to 6 of 6

Thread: [2005] Changes not making it to dataset

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Angry [2005] Changes not making it to dataset

    Using the following to fill dataset:

    vb.net Code:
    1. jobDA = New OleDb.OleDbDataAdapter("SELECT * FROM jobs WHERE jobs.jobno = " & JobNo, con)
    2. jobDA.Fill(jobDS)

    Then adding databinding to textbox in form:
    vb.net Code:
    1. Dim tbl As DataTable = jobDS.Tables(0)
    2. Me.txtOrderNo.DataBindings.Add("text", tbl, "OrderNo")

    When i change the value of txtOrderNo jobDS.HasChanges stays false.
    This is code which i have used before and worked fine. Any ideas?

    TIA

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

    Re: [2005] Changes not making it to dataset

    Are you ending the editing session? To do so you would have to leave the TextBox. You should use a BindingSource between the table and the control, then you can just call its EndEdit method to commit any pending changes.
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: [2005] Changes not making it to dataset

    yes i am leaving the textbox, i'm checking jobds.haschanges on leave of the form.

    Do you think using a bindingsource is a better way of doing things? could you point to an example of how to use it, have just had a go but couldn't work it.

    Thanks

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

    Re: [2005] Changes not making it to dataset

    I use a BindingSource at least 99 times out of 100 when data-binding. An example of how to use it? The class documentation is where you should be looking first on all occasions.
    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2007
    Posts
    351

    Re: [2005] Changes not making it to dataset

    Thanks jm, yea did check the docco.

    Thing i cant figure out is how to use it with controls that dont have a datasource property, ie a textbox or label. All the examples i can find are for datagrids or list boxes. Can i have a clue

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

    Re: [2005] Changes not making it to dataset

    Even if a control supports complex data-binding via a DataSource property, all controls support simple data-binding to a single property via their DataBindings collection. You can bind a property to any object that way, including a BindingSource.
    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