Insert from DataTable

  • Thread starter Thread starter Necqui Teja
  • Start date Start date
N

Necqui Teja

Is there a quick and effcient way to insert records into SQL Server database
from a DataTable (DataTable dt;) when the DataTable and the SQL Server
database contain the same field names and attributes.

I'm using VS2005 Beta 2.

Thanks.
 
Necqui,

The best way to do this would be to configure a SqlDataAdapter with the
appropriate InsertCommand (because you are adding records), and then pass
the DataTable to the Update method.

Hope this helps.
 
Hi,

Where you get the data from?

You can check the DataRow.RowState to see the status of the row, then you
could run the required query (Update, Insert ) or as Paldino said use the
SqlDataAdapter.


cheers,
 
Back
Top