Sequence to connect and retrieve data from database useig
dataset ?

Answer Posted / vaidyanathan r.

The sequence is
Step 1: Create a Connection Object with Connection String
Eg: <Provider**>Connection ActiveConnection = new
<Provider**>Connection(<ConnectionString>)

Step 2: Create a Command Object with Command Text and the
created Connection Object

Eg: <Provider**>Command Qry = new <Provider**>Command
(<Command Text>, ActiveConnection)

Step 3: Set the command Type for the created Command
Eg: Qry.CommandType = CommandType.Text

Step 4: Create Data Adapter with the created Command
Eg: <Provider**>DataAdapter da = new
<Provider**>DataAdapter(Qry*);

Step 5: Create a DataSet Object.
Eg: DataSet ds = new DataSet();

Step 6: populate the dataset by calling the fill method of
Data adaper against the Data set object
Eg: da.Fill(ds);

__________________________________________________________
*Qry contains a select query (or) Stored Procedure Name
containing a Select Query

** If the provider is SQL server then the Connection type
is SQLConnection, Command type is SQLCommand and Data
adapter type is SQLDataAdapter.

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does entity framework work?

461


What is difference between entity framework and ado.net?

473


What is the namespaces being used to access oracle database?

510


What is namespace in ado.net?

494


Explain the difference in record set and dataset?

482






What is the default Timeout for SqlCommand.CommandTimeout property?

499


Can you explain how to enable and disable connection pooling?

498


Define atomicity?

571


What is ole access?

542


What does ado stand for in ado.net?

448


How does ado.net work?

486


Define bubbled event?

505


What is a dynaset in access?

518


What are the classes in System.Data.Common Namespace?

695


What is the executescalar method?

576