SQL database table ot SQL schema

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
 
H

Hans Kesting

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;
}
 
M

Mythran

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top