Cor, I think you are leaving out ADOX, which can do what Julie is talking
about. I know that ADOX is not the ADO.NET way of doing things, but,
sometimes you have to do something like that.
For instance, I have a very old ( in computer years) DOS based database
programs that used 63 individual data files (old Dataflex 3.1d .DAT
format) that each contain a single table. And none of those tables have
the same formating( Schema). I have been able to export all of those
individual files & their associated tables to CSV format and then read
them into a utility application that I am still working on,
and use the Dataset that is filled by the CSV file as a template to build
a new Access database with a table that has the same structure as the
Dataset built from the CSV file. And I am building the Access database
and Table with ADOX. And then filling the new table from the CSV file.
All without having to know ahead of time the exact format of the original
file(s).
That means I have to step thru the dataset and get all the Column Header
names, their types, Field Sizes etc. and apply that to the new Table that
I am creating and then step thru each row in the Dataset and add the
actual data to the new Table. I have run into a few problems with this
but, it is mostly because of my lack of knowledge of ADOX and the methods
to use it.
So, there are other ways besides, using SQL statements to build a new
table and database. And without having to know the exact details ahead of
time when you create the SQL statements to build the new table.
james
Cor Ligthert said:
Julie,
You cannot, you have to create the datatable using the SQL CREATE TABLE
And as I forever write with this or make it yourself generic (what should
be possible) and than sent the code to this newsgroup, than we can supply
it the next time.
Sorry this has always the same answer.
Beneath a sample how to make Access tables in Adonet.
\\\
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& _
" Data Source="FullPath";User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE persons ( " & _
"AutoId int identity ," & _
"Id int NOT NULL," & _
"Name NVarchar(50)," & _
"BirthDate datetime," & _
"IdCountry int," & _
"CONSTRAINT [pk_AutoId] PRIMARY KEY (AutoId)) ", conn)
conn.Open()
Try
cmd.ExecuteNonQuery()
Catch ex As OleDb.OleDbException
MessageBox.Show(ex.Message, "OleDbException")
Exit Sub
Catch ex As Exception
MessageBox.Show(ex.Message, "GeneralException")
Exit Sub
End Try
conn.Dispose()
End Sub
End Class
///
I hope this helps?
Cor
JuLiE Dxer said:
I have a DataTable schema already created programmatically,
dynamically and added to a DataSet.
The trick is placing this created DataTable into a blank database file
where no tables exist yet.