Home All Groups Group Topic Archive Search About

Get Query string from Dataset/Datatable

Author
27 Oct 2007 9:47 PM
Johnny E. Jensen
Hello

When i fetch data from database i do the following:

DataSet ds = new DataSet();
OledbConnection con = new OledbConnection(ConnectionString);
using ( OledbCommand cmd = con.CreateCommand())
{
    cmd.CommandText = "SELECT * FROM [tblCustomers] WHERE [CustomerName]
LIKE 'A%';";
    using ( OledbDataAdapter da = new OleDbDataAdapter(cmd))
    {
        da.Fill(ds);
        ds.Tables[0].TableName = "tblCustomers";
    }
}

The above just ment as an illustration.
The DataSet ds now contain one table with the result of the query within the
cmd.
Now my question, is the cmd Query stored somewhere within the DataSet/Table?

Kind regards

Johnny E. Jensen

Author
28 Oct 2007 3:10 PM
Norman Yuan
No. DataSet/Table is disconnected data model, which has no knowledge about
the data source which its data may be from.


Show quote
"Johnny E. Jensen" <joh***@XXemde.dk> wrote in message
news:uzg2WKOGIHA.4712@TK2MSFTNGP04.phx.gbl...
> Hello
>
> When i fetch data from database i do the following:
>
> DataSet ds = new DataSet();
> OledbConnection con = new OledbConnection(ConnectionString);
> using ( OledbCommand cmd = con.CreateCommand())
> {
>    cmd.CommandText = "SELECT * FROM [tblCustomers] WHERE [CustomerName]
> LIKE 'A%';";
>    using ( OledbDataAdapter da = new OleDbDataAdapter(cmd))
>    {
>        da.Fill(ds);
>        ds.Tables[0].TableName = "tblCustomers";
>    }
> }
>
> The above just ment as an illustration.
> The DataSet ds now contain one table with the result of the query within
> the cmd.
> Now my question, is the cmd Query stored somewhere within the
> DataSet/Table?
>
> Kind regards
>
> Johnny E. Jensen
>

AddThis Social Bookmark Button