DataSet Tables to SQL Server Database

F

Frank Uray

Hi all

For example: I have a DataSet with two tables
and one relation between each other.

Is there a direct way to publish this tables
to the SQL Server even when the tables
dont exists ?
I know, using SqlDataAdapter, it is possible
to update/insert/delete data. But for
this, the table has to exists ...

Thanks for any help !

Best regards
Frank Uray
 
A

Alberto Poblacion

Frank Uray said:
For example: I have a DataSet with two tables
and one relation between each other.

Is there a direct way to publish this tables
to the SQL Server even when the tables
dont exists ?

No, there is no "direct" way in ADO.NET to create the tables on the
server. You would have to build a "CREATE TABLE ..." statement, and then
submit it to the server by means of a SqlCommand and ExecuteNonQuery().
I know, using SqlDataAdapter, it is possible
to update/insert/delete data. But for
this, the table has to exists ...

Once the table exists (because you sent the CREATE TABLE), the best way
to populate it from a DataTable is to use a SqlBulkCopy object. This is
faster than a SqlDataAdapter, and also easier to configure if you are
building your dataadapter from scratch.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top