RE: Novice: How to modify rows (not add) using a script component
- From: changliw@xxxxxxxxxxxxxxxxxxxx (Charles Wang[MSFT])
- Date: Mon, 07 Aug 2006 11:29:18 GMT
Hi Sharkir,
Thanks for your response.
Because of a bulk update, I recommend that you use a select command to
query the data source and fill the data into a dataset or datatable and
then loop fetch each row from the datatable and then use a update command
to update the row to the destination. I can give you some general
suggestions, but please understand that I'm not an expert on ADO.NET.
Here is a simple example (C#):
DataSet ds = new DataSet();
SqlDataAdapter adpSrc = new SqlDataAdapter();
adpSrc.SelectCommand = new SqlCommand("select * from
...",connection_source);
adpSrc.Fill(ds);
SqlDataAdapter adpDest = new SqlDataAdapter();
SqlCommand updateCmd = new SqlCommand("update ... set field1=@field1,
field2=@field2 where ID=@ID",connection_destination);
adpDest.UpdateCommand = updateCmd;
updateCmd.Parameters.Add("field1","SqlDbType.varchar",20,"@field1");
updateCmd.Parameters.Add("field2","SqlDbType.int",8,"@field2");
updateCmd.Parameters.Add("ID","SqlDbType.Int",8,"@ID");
If(ds.Tables.Count>0)
{
ds.Tables[0].Name = "database table name";
adpDest.Update(ds.Tables[0]);
}
In fact, there are also many other ways to access SQL Server by ADO.NET.
You can also loop update the rows by the query result set. I recommend that
you borrow a book regarding ADO.NET. It will lead you to master this
technic quickly.
Charles Wang
Microsoft Online Community Support
.
- References:
- RE: Novice: How to modify rows (not add) using a script component
- From: Charles Wang[MSFT]
- RE: Novice: How to modify rows (not add) using a script component
- From: Charles Wang[MSFT]
- RE: Novice: How to modify rows (not add) using a script component
- From: Charles Wang[MSFT]
- RE: Novice: How to modify rows (not add) using a script component
- Prev by Date: Re: Returning value from SQL Task
- Next by Date: dts package sometimes stops executing
- Previous by thread: RE: Novice: How to modify rows (not add) using a script component
- Next by thread: RE: Novice: How to modify rows (not add) using a script component
- Index(es):
Relevant Pages
|