How do you update a Dataset in ADO.Net and How do you update database through Dataset

Questions by sbehera02   answers by sbehera02

Showing Answers 1 - 12 of 12 Answers

syed abdul kather

  • Dec 21st, 2006

i am not sure that this is right we can update our dataset by updating data adapter ex :- string str="Provider=Microsoft.Jet.OLEDB.4.0;Data Source= My Documents/syed.mdb"; OleDbConnection con=new OleDbConnection(str); OleDbDataAdapter ada=new OleDbDataAdapter("select * from student",con); DataSet ds=new DataSet(); ada.Update(ds,employee); DataGrid1.DataSource=ds.Tables[0].DefaultView; DataGrid1.DataBind();

  Was this answer useful?  Yes

dharmesh kubavat

  • Feb 8th, 2007

Using Update method of Data Adapter : DA.Update(DS)

  Was this answer useful?  Yes



Step 1:

 //Fill the DataSet by using SqlDataAdapter (sDa)
sDa.Fill(ds)// ds is DataSet Object

Step two:

   // Change DataSet and update by using  sDa.update(datasetopbject) Method

    sDa.update(ds);//it will update DataBase



  Was this answer useful?  Yes


  • Apr 18th, 2008

It's sure u can easily update the data by using the code as following:

DataSet objDataset1 = new DataSet();



  Was this answer useful?  Yes


  • Apr 18th, 2008

And updating database through dataset will be by following code:

foreach (DataRow row in objDataset1.Tables[0].Rows)


string Loannumber = row[0].ToString();int count = bllObj.Savenumber(number,DateTime.Now);

total += count;


where bll is the object of business layer

  Was this answer useful?  Yes


  • May 1st, 2008

a. Update a dataset;
Dataset ds = new dataset();
SqlDataAdapter adp = new SqlDataAdapter(Query,connection);
Again you can add/update Dataset as below
SqlDataAdapter adp1 = new SqlDataAdapter(Query1,connection);

b. Update database through dataset.
SqlCommandBuilder mySqlCommandBuilder = new SqlCommandBuilder(mySqlDataAdapter);
Foreach(datarow dr in ds.table[0].rows)
Dr[“column Name”] = “value”;


  • Oct 31st, 2011

we can update Dataset in ADO.Net using "AcceptChanges" method of dataset and
we can update database through dataset using "Update" method of data adapter with parameter as dataset (from which database to be updated).

  Was this answer useful?  Yes

lata negi

  • Nov 4th, 2011

  1. SqlConnection conn = new SqlConnection("Server=__; DataBase=__; UID: __; Password: __");

  2. DataAdapter da;

  3. DataSet ds = new DataSet();

  4. da = new SqlDataAdapter("select * from employee", conn);

  5. ds = da.fill(ds);

  6. GridView.DataSource=ds;

  7. GridView.DataBind();


  Was this answer useful?  Yes

brajesh gautam

  • Feb 6th, 2012

In ADO.Net if you use the disconnect mode then local copy are already update but if we want to update a database type this program in visual studio

sqlconncection = new sqlconection (" connection string");

take a date set;
dataset ds;

and take sqldata adaptor da;
and give the command in data adptor

tables [0];
is your index

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions