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

Tags: ,

Sponsored Links



Update command of Dataset In C#

Software Development


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
Zecho's Avatar
Member
 
Join Date: May 2008
Posts: 2,267
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
Reegan's Avatar
Member
 
Join Date: Oct 2005
Posts: 2,299
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


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
Dataset vs DataReader in .Net Vireshh Software Development 3 07-05-2011 12:32 PM
How to create a new DataSet Leonard Windows Software 5 23-03-2010 09:52 AM
How to use dataset in ASP.Net? Roxy_jacob Software Development 3 28-11-2009 06:13 PM
How is DataSet.xsd used in any particular website Guns-n-Roses Software Development 3 25-09-2009 01:52 PM
Working with XML and DataSet Aanand Software Development 3 01-05-2009 03:38 PM


All times are GMT +5.5. The time now is 03:44 AM.