I'm not exactly sure what you need, but let me take a shot
it.
If you run a query for instance, SELECT * FROM someTable
and use a SQLDataReader for instance, you can choose you
could use something like DataTable dt =
myDataReader.GetSchemaTable();
This will give you all of the information about the schema
that was used in the query. 'Connect every time' though
is what I'm wondering about. Since you are disconnected,
if the structure changes, you won't know about it without
either re-querying the DB or using some fancy footwork
with SQL Server Notification.
Anyway, once you have your datatable, add it to the
dataset and you have that
information....myDataset.Tables.Add(dt);
If you need all of the information in all of the tables of
the db, you could query SysObjects like SELECT NAME FROM
Sysobjects wherek XType = 'U'...you can use a DataReader
ro DataTable, but it'd probably make more sense to use a
Reader since you don't update this table. Then, you could
iterate through it and add the schema information to the
dataSet like this.
Dim cmd as New SqlCOmmand
While dr.Read()
sql = SELECT * FROM & dr(0)
Dim dta as New DataTable
If cn.State <> ConnectionState.Open then cn.Open
cmd.CommandText = sql
dr = cmd.ExecuteReader(CommandBehavior.SchemaOnly)
Dim dt as new DataTable
dt = dr.GetSchemaTable
myDataSet.Tables.Add(dt)
dr.Close
cn.Close
End While
Note that this is pseudo-code for how to attempt it but
it's pretty close to what would work. By using the
SchemaOnly, you'd accomplish your goal of getting an empty
datatable with the column info.
Good Luck,
Bill