SQL database table ot SQL schema

Discussion in 'ASP .Net' started by Paul M, Dec 8, 2003.

  1. Paul M

    Paul M Guest

    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, Dec 8, 2003
    #1
    1. Advertising

  2. Paul M

    Hans Kesting Guest

    "Paul M" <> wrote in message
    news:Okn4p%...
    > 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, Dec 8, 2003
    #2
    1. Advertising

  3. Paul M

    Mythran Guest

    "Hans Kesting" <> wrote in message
    news:...
    >
    > "Paul M" <> wrote in message
    > news:Okn4p%...
    > > 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)
    > {



    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
    Mythran, Dec 8, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,497
    Markus
    Nov 23, 2005
  2. Klaus Johannes Rusch

    Re: Convert DB2 schema to XML Schema

    Klaus Johannes Rusch, Aug 6, 2003, in forum: XML
    Replies:
    0
    Views:
    549
    Klaus Johannes Rusch
    Aug 6, 2003
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,170
    Stanimir Stamenkov
    Apr 25, 2005
  4. Manuel
    Replies:
    0
    Views:
    493
    Manuel
    Sep 28, 2005
  5. donet programmer
    Replies:
    1
    Views:
    502
    donet programmer
    Dec 5, 2006
Loading...

Share This Page