|
| |||||||||
| Tags: command, dataset |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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
| ||||
| ||||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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. |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |