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

What is the use of connection object in ado.net?

780


What are the core objects of ADO.NET?

790


Which one of the following objects is a high-level abstraction of the connection and command objects in ado.net?

826


What is the difference between sqlcommand and sqldataadapter?

727


What is connected architecture in ado.net?

699


What are the differences between OLEDB and SQLClient Providers?

776


How to retrieve the user id which is provided while windows authentication?

812


What are the advantages of ado.net?

683


Define connection string?

791


What do you know about ado.net's objects?

713


What are the objects of ado.net?

770


What is the functionality of data provider in ado.net?

679


What is DataReader Object?

785


What are the essential features of ado.net?

723


What is bubbled event?

729