Results 1 to 6 of 6

Thread: why can't update database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    why can't update database

    this code is work (can update my database)
    VB Code:
    1. Dim dt = DataSet11.Tables("Customer")
    2.         dt.Rows(myMgr.Position)("CustomerPersonalID") = [COLOR=Red]1234567890[/COLOR]
    3.  
    4.         OleDbDataAdapter1.Update(DataSet11, "Customer")
    5.         DataSet11.AcceptChanges()

    but this code can't update my database
    VB Code:
    1. Dim dt = DataSet11.Tables("Customer")
    2.         dt.Rows(myMgr.Position)("CustomerPersonalID") = [COLOR=Red]txtCustomerPersonalID.Text[/COLOR]
    3.  
    4.         OleDbDataAdapter1.Update(DataSet11, "Customer")
    5.         DataSet11.AcceptChanges()

    was i do wrong ?
    thanks!

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

    Re: why can't update database

    1234567890 is a number. txtCustomerPersonalID.Text is a string. If the second represents a number then it may be implicitly converted, although I wouldn't count on it. If it doesn't represent a number then it definitely won't work.
    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
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: why can't update database

    how to resloved this problem ?
    i'm .net newbie

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

    Re: why can't update database

    Validate the contents of the TextBox and convert it to a number.
    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
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: why can't update database

    If you're using VB 2005 look up the Integer.TryParse method. If it's an earlier version look up the Double.TryParse method
    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

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Feb 2006
    Posts
    27

    Re: why can't update database

    sometime my data can use char ex: A0137521
    is anyway to dt.Rows(myMgr.Position)("CustomerPersonalID") = String

    thanks!
    ekkapop

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