Reading from database1 writing to database2

  • Thread starter Thread starter Michael Jones
  • Start date Start date
M

Michael Jones

Ok......... here's my dilemma. I'm filtering rows from a Sql
Datatable in my server. How can I write those filtered rows onto new
Datatable in the same server. I'm trying to use c# to accomplish
this. I'm new at C# guys, bare with me!
 
Michael Jones said:
Ok......... here's my dilemma. I'm filtering rows from a Sql
Datatable in my server. How can I write those filtered rows onto new
Datatable in the same server. I'm trying to use c# to accomplish
this. I'm new at C# guys, bare with me!

You could probably do this with one single SQL query, but if you have a need
to do it in C#, your workflow would be like this.


1. Write a function that takes parameters for each column in the new
datatable. Inside the function write a SqlCommand that takes these
parameters and does an insert into the database.
2. Create an ADO.Net SqlDataAdapter with the SQL query needed to put the
rows in a datatable, and the connection string
3. Fill a new DataTable with the SqlDataAdapter you just created
4. Do a foreach loop on DataRows in the DataTable. For each one, call the
function you wrote in #1.

R.
 
Thanks Richard.................. I already had my DataTable but wasn't
sure how to send that info back to my database. I'll let you know how
it turns out.

M
 
Back
Top