Results 1 to 2 of 2

Thread: plz help! how to update rows in dataset

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    65

    plz help! how to update rows in dataset

    i want to update rows and make changes to database but i've got this error

    error:Error 1 No overload for method 'Update' takes '2' arguments
    Code:
     rowIndex = serviceLogDataGridView.CurrentCellAddress.Y;
    
                        dsJPS.Tables["ServiceLog"].Rows[rowIndex]["Date_Serve"] = dateTimePicker1.Value;
                        dsJPS.Tables["ServiceLog"].Rows[rowIndex]["tech_Assigned"] = comboBox1.SelectedValue.ToString();
                        this.serviceLogBindingSource.EndEdit();
                        this.serviceLogTableAdapter.Update(newSet, "ServiceLog");

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

    Re: plz help! how to update rows in dataset

    First up, you can't just make up what parameters a method has. As you type, Intellisense will tell you want parameters a method has so you have to provide suitable arguments. You've obviously just typed something in there that had no similarity to what Intellisense told you. Take notice of the information the IDE is trying to give you.

    Apart from that, if you've got a TableAdapter then you've got a typed DataSet, yet you're using it like it's untyped, which is a waste. If you're going to create a typed DataSet then use it. Assuming that 'dsJPS' is your typed DataSet, this:
    csharp Code:
    1. dsJPS.Tables["ServiceLog"].Rows[rowIndex]["Date_Serve"] = dateTimePicker1.Value;
    should be this:
    csharp Code:
    1. dsJPS.ServiceLog[rowIndex].Date_Serve = dateTimePicker1.Value;
    If 'dsJPS' isn;t your typed DataSet then why do you have it at all? Maybe 'newSet' is your typed DataSet. If so, what's 'dsJPS' for?

    It looks to me like you're trying to use the TableAdapter like it's a DataAdapter. You don't pass the name of the table to the Update method of a TableAdapter because it already knows what table it's updating, which is the whole point of TableAdapters.
    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