Hi
Dudes
Is it possible , i have two tables in data set and i want to perform DML operation on that tables like delete , update and insert , if it is possible how can any one help me...?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jul 27, 2011, 9:17 AM
When you call da.Update(ds),then it should update the database with any insertions, updates or deletions to rows in the DataTables within the DataSet that have not yet been committed.
VulpesPosted Jul 27, 2011, 10:01 AM
Thanks :)
Smart LuckyPosted Jul 27, 2011, 8:54 AM
can you send this program in sqlclient...? and if i updates and delete in data set can these chages perform on database in actual data....?
Jiteendra SampathiraoPosted Jul 26, 2011, 9:50 AM
it is possible.....
String cs = String.Format(@"Provider=SQLNCLI;Data Source=
using (OleDbConnection con = new OleDbConnection(cs))
{
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Shippers", con);
DataSet ds = new DataSet("ShipperDataSet");
da.Fill(ds);
// Create Update and Insert commands
OleDbCommandBuilder cmdBuilder = new OleDbCommandBuilder(da);
da.UpdateCommand = cmdBuilder.GetUpdateCommand();
da.InsertCommand = cmdBuilder.GetInsertCommand();
// Insert row
DataRow newRow = ds.Tables[0].NewRow();
newRow["ShipperID"] = 100;
newRow["CompanyName"] = "NewCompany";
newRow["Phone"] = "123456789";
ds.Tables[0].Rows.Add(newRow);
// Update row
ds.Tables[0].Rows[0][1] = "Changed CompanyName";
// Update database using Dataset via DataAdapter
da.Update(ds);
}
Go through this LiNK
hope it help you.....