"Paul M" <mi******@hotmail.com> wrote in message
news:Ok****************@TK2MSFTNGP12.phx.gbl...
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;
}