Saving a Dataset

  • Thread starter Thread starter Fred Chateau
  • Start date Start date
F

Fred Chateau

If I have a dataset in memory, can I save that dataset to a SQL database
without having a schema or manually creating the tables?
 
I am pretty sure you cant, if you could it would be supported in the data
adapter class , although you can do it the other way i.e dynamically create a
dataset from a data source.
 
Hi,

How you want to save it?

You could save it as a Text, this would create one record for the entire
Dataset
 
I thought it wasn't possible but I wanted to check anyway.

I'm reading an XML document into a dataset and I need to save it to a
relational database. I've been having problems with SSIS and thought maybe I
could do it directly in C#.

I generated a schema from the XML document. I suppose I'll have to examine
the schema and create tables manually in SQL Management Studio.

It would help if you could point me to some code on how to write the dataset
to the database once I have the tables set up.

Thanks.
 
You can save it as XML in the database, if that is your aim.

If you can get the same data shape out of the database, you can move the
actual data over to that DataSet and fire Update.

Or, if you can figure out how to map the data to your database schema, you
can use the XML features of SQL Server to rip through the DataSet XML and
save it to the proper tables. This requires writing a stored procedure or
possibly complex in-line SQL, but it can be done.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
 
I am trying to map the XML schema to a relational database schema. I've made
some progress using SSIS but not without problems (see my post in
sqlserver.integrationsvcs: Setting Default Identity Datatypes).

What is the code to call Update on a DataAdapter while passing in an
external dataset? Can I use Select statements to query from the dataset into
a smaller set of tables in the database?

FYI, Cowboy, we're upgrading HMN to Virtual Earth.
 
Hi,



Fred Chateau said:
I thought it wasn't possible but I wanted to check anyway.

I'm reading an XML document into a dataset and I need to save it to a
relational database. I've been having problems with SSIS and thought maybe
I could do it directly in C#.

I generated a schema from the XML document. I suppose I'll have to examine
the schema and create tables manually in SQL Management Studio.

That is always an option, if you do not have that many tables it might be
the fastest one.

Otherwise you could use the XML and transform it in the T-SQL statements
that create the tables :) , you may even find some tool that does this in
the web (if you do , please post it back)
 
I suppose you could say that I've decided to build my own tool to transfer
the data, using an XML DataSet in Visual Studio. I'll post the code
somewhere when it's completed, if anyone's interested.
 
Back
Top