Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 07-01-2009
Member
 
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?
Reply With Quote
  #2  
Old 07-01-2009
Member
 
Join Date: May 2008
Posts: 2,293
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);
Reply With Quote
  #3  
Old 07-01-2009
Member
 
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 .
Reply With Quote
  #4  
Old 07-01-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 01:15 PM.