SQL database table ot SQL schema

  • Thread starter Thread starter Paul M
  • Start date Start date
P

Paul M

Hi there,

what is the easiest way i can call a SQL Query statement, eg. "SELECT * FROM
CUSTOMER", and have something, either some kinda object or something else,
that will show me the fields that have been returned, possibly also with
their properties?

similar thing to the normal ASP:

for each field in recordset.fields....and so on.
thanks.
PM
 
Paul M said:
Hi there,

what is the easiest way i can call a SQL Query statement, eg. "SELECT * FROM
CUSTOMER", and have something, either some kinda object or something else,
that will show me the fields that have been returned, possibly also with
their properties?

similar thing to the normal ASP:

for each field in recordset.fields....and so on.
thanks.
PM

Use a DataAdapter to fill a DataSet. The Tables within that have a Columns
collection.

private DataSet GetDataSet(string pCmdString)
{
DataSet ds;
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(_ConnStr); // the connection
string
cmd.Connection = conn;
cmd.CommandText = pCmdString; // a "select *" sql-query
cmd.CommandType = CommandType.Text;
cmd.Connection.Open();
try
{
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
ds = new DataSet();
da.Fill(ds);
}
finally
{
cmd.Connection.Close();
}
return ds;
}
 
Hans Kesting said:
Use a DataAdapter to fill a DataSet. The Tables within that have a Columns
collection.

private DataSet GetDataSet(string pCmdString)
{


On that note, take a look at "Microsoft Application Blocks for .NET" located at
microsoft.com

MSDN Home > MSDN Library > .NET Development > Building Distributed Applications
with .NET > Microsoft Application Blocks for .NET

Mythran
 
Back
Top