Results 1 to 4 of 4

Thread: Update command of Dataset In C#

  1. #1
    Join Date
    Dec 2008
    Posts
    10

    Update command of Dataset In C#

    Hi,

    I am using the C# as frontend and MS Access a backend.
    I have a Insert statement to insert new records into the Access database, but how do i Update the dataset?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Update command of Dataset In C#

    Hi,

    The approach that you are doing is quite the reverse. You must first edit your dataset then send the updates to your access database. To do this you must have a activeconnection, adapter and a dataset. eg:

    OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM myTable", con);
    OleDbCommandBuilder cm = new OleDbCommandBuilder(adapter);
    ...
    // Fill the DataSet and edit
    adapter.Fill(ds);
    ds.Tables[0].Rows[10]["field1"] = "TEsting";
    // send updates to database
    adapter.Update(ds);

  3. #3
    Join Date
    Dec 2008
    Posts
    10

    Re: Update command of Dataset In C#

    I am using the insert command to update the database. so now How do u update the dataset? Do u refill it .

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Update command of Dataset In C#

    You can follow this method,

    adapter.InsertCommand = new SqlCommand("INSERT INTO myTable VALUES(@Id)", conn);
    adapter.InsertCommand.Parameters.Add("@Id", ...);

    Sending Insert statements directly to the database is not a very good idea if your using a dataset. You must edit your dataset, then using your adapter, send the changes to your database.

Similar Threads

  1. Unable to update my database using insert command
    By Govardhann in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 11:10 AM
  2. How to use dataset in ASP.Net?
    By Roxy_jacob in forum Software Development
    Replies: 3
    Last Post: 28-11-2009, 06:13 PM
  3. Can Windows Update be run from the command line?
    By Xena in forum Networking & Security
    Replies: 4
    Last Post: 24-07-2009, 05:10 PM
  4. DataAdapter.Update command is not updating the database.
    By Kiran123 in forum Software Development
    Replies: 3
    Last Post: 03-02-2009, 06:34 PM
  5. Command to force reinstallation of windows update
    By Luis S in forum Server Update Service
    Replies: 1
    Last Post: 10-05-2007, 09:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,935,915.87015 seconds with 16 queries