how to export dataset to sql or access

G

Guest

This question is similar to one asked previously, but I'm wondering how to
automate the process.

My program queries a custom library object which returns a DataSet result.
The library is configured to act as a method for querying databases (sql or
mdb) and passing back the resulting data.
Note: This library is a required part of my project and must be included.

On to the question...
I have a DataSet with a DataTable in it, and I need to export this to a SQL
server or to an Access (mdb) file to use as a temporary sandbox, since I'm
unable to modify the original data. The data in the sandbox will be heavily
modified and needs to be seperate from the original.

I _do_ know the schema of the tables I want to write/export, but I have a
dozen or so of them and automating the process would be wonderful. I
understand I have to use the SQL CREATE TABLE command, but is there a way to
generate a CREATE TABLE string using the field names and datatypes from my
DataTable?

Thanks in advance.

PS: Any samples in C# would be extremely helpful.
 
G

Guest

Hi cpuckle,


You can loop thru Datatable.Columns to get Column.ColumnName and
Column.DataType. And accordingly dynamically generate Create Table statement.

Then there are many ways to insert dataset data to db.

HTH

Elton Wang
(e-mail address removed)
 
G

Guest

Thank you for the response. I figured that was the right approach, but wasn't
completely sure.

(Sorry for the multiple posts, but when I first tried it told me there was
an error and to try again [later]. I was a bit overzealous with the clicking.)

-clay
 

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