XML to SQLCE

  • Thread starter Thread starter Amirallia
  • Start date Start date
A

Amirallia

Hi,

I want to import my data from a XML file to a SqlCE db. I use VB.NET

What's the best solution to do this ?

Thanks
 
Amiralla,

The easiest way would be to read the XML into a DataSet using
DataSet.ReadXml and then write that out to your SqlCe file.
 
Ginny Caughey [MVP] avait soumis l'idée :
Amiralla,

The easiest way would be to read the XML into a DataSet using DataSet.ReadXml
and then write that out to your SqlCe file.

But do you think I must create the structure of the tables, or there is
a methode that do this at runtime?

The readXML methode read the XML file and how put the data into the
table of my DB?
 
You will need to create the tables in your database. There is no automatic
way to do this, so you'll have to example the tables in the dataset,
enumerate their columns and piece together a CREATE TABLE sql statement,
then you can import the data.

Peter
 
Peter Foot [MVP] a présenté l'énoncé suivant :
You will need to create the tables in your database. There is no automatic
way to do this, so you'll have to example the tables in the dataset,
enumerate their columns and piece together a CREATE TABLE sql statement, then
you can import the data.

Peter

ok here is my xml file and I create my table like this

Cmd.CommandText = "CREATE TABLE T_EQUI (" & _
"TEQ_ID int NOT NULL ," & _
"TEQ_LIBELLE nvarchar (50) NULL)"
Cmd.ExecuteNonQuery()
Cmd.CommandText = "ALTER TABLE T_EQUI ADD CONSTRAINT PK_T_EQUI
PRIMARY KEY (TEQ_ID)"
Cmd.ExecuteNonQuery()


So waht code must I write to load the XML data into my SQLCE table
"T_EQUI" ?

Thanks
 
Peter Foot [MVP] avait soumis l'idée :
You will need to create the tables in your database. There is no automatic
way to do this, so you'll have to example the tables in the dataset,
enumerate their columns and piece together a CREATE TABLE sql statement, then
you can import the data.

Peter

ok here is my xml file and I create my table like this

Cmd.CommandText = "CREATE TABLE T_EQUI (" & _
"TEQ_ID int NOT NULL ," & _
"TEQ_LIBELLE nvarchar (50) NULL)"
Cmd.ExecuteNonQuery()
Cmd.CommandText = "ALTER TABLE T_EQUI ADD CONSTRAINT PK_T_EQUI
PRIMARY KEY (TEQ_ID)"
Cmd.ExecuteNonQuery()


So waht code must I write to load the XML data into my SQLCE table
"T_EQUI" ?

Thanks
 
Back
Top