getting database table schema

  • Thread starter Thread starter Saso Zagoranski
  • Start date Start date
S

Saso Zagoranski

Hi!

A question about database tables...
I have a SELECT statement:
SELECT something FROM someTable WHERE code = @code

The parameter code starts with 1 and is autoincremented...

Now I want to add a row to the database and I do it like this:
DataSet dataSet = new DataSet();
dataAdapter.SelectStatement.Parameters[0].Value = 0; // *
dataAdapter.Fill(dataSet); //
*
dataSet.Tables[0].AddRow(....);

The question is about the two rows marked with a *... I do this only to get
the schema of the table...
Is there anyother way to get the schema of the table? And can you the update
just the DataTable, without
it being in a DataSet?

thanks,
saso
 
Hi!

A question about database tables...
I have a SELECT statement:
SELECT something FROM someTable WHERE code = @code

The parameter code starts with 1 and is autoincremented...

Now I want to add a row to the database and I do it like this:
DataSet dataSet = new DataSet();
dataAdapter.SelectStatement.Parameters[0].Value = 0; // *
dataAdapter.Fill(dataSet);
// *
dataSet.Tables[0].AddRow(....);

The question is about the two rows marked with a *... I do this only
to get the schema of the table...
Is there anyother way to get the schema of the table? And can you the
update just the DataTable, without
it being in a DataSet?

thanks,
saso

HI Saso,

Why don't you perform the update directly with an SqlCommand object if
you don't want to use the DataSet?

A dataTable can be used only in conjunction with a DataSet. So your only
chance is either to use the DataSet features or to stick with standalone-
commands.

greets
Peter

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
Thanks Peter!

Good point... I'll try and use the SqlCommand instead :)

saso

Peter Koen said:
Hi!

A question about database tables...
I have a SELECT statement:
SELECT something FROM someTable WHERE code = @code

The parameter code starts with 1 and is autoincremented...

Now I want to add a row to the database and I do it like this:
DataSet dataSet = new DataSet();
dataAdapter.SelectStatement.Parameters[0].Value = 0; // *
dataAdapter.Fill(dataSet);
// *
dataSet.Tables[0].AddRow(....);

The question is about the two rows marked with a *... I do this only
to get the schema of the table...
Is there anyother way to get the schema of the table? And can you the
update just the DataTable, without
it being in a DataSet?

thanks,
saso

HI Saso,

Why don't you perform the update directly with an SqlCommand object if
you don't want to use the DataSet?

A dataTable can be used only in conjunction with a DataSet. So your only
chance is either to use the DataSet features or to stick with standalone-
commands.

greets
Peter

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
maybe this will help.
//------------------------------------------------------------------
DB_Connection.Open();
// Get the Table Names from DataBase
DB_SchemaTable =
DB_Connection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,
new object[] {null, null, null, "TABLE"});
// Reserve the Strings for the Table Names
sa_TableNames = new String[DB_SchemaTable.Rows.Count];
for (int i=0;i<DB_SchemaTable.Rows.Count;i++)
{
DataRow dr_Row = DB_SchemaTable.Rows;
// Store the Table Name
sa_TableNames = dr_Row["TABLE_NAME"].ToString();
}



Mark Johnson, Berlin Germany
(e-mail address removed)
 
Back
Top