Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write steps of retrieving data using ado.net ?

Answer Posted / senthil kumar

we can use two ways to retrieve the data from database
1 -> data reader
2 -> data adapter

when you use datareader
create connection object and open the connection
SqlCommand cmd = new SqlCommand(sql,con);
cmd.CommandType = CommandType.Text;
SqlDataReader sread = cmd.ExecuteReader();
while(sread.Read())
{
String data1 = sread.GetString(0);
int data2 = sread.GetValue(1);
String data3 = sread.GetString(2);
}

when u use the dataadapter

create the connection and open
SqlDataAdapter sda = new SqlDataAdapter(sql,con);
DataSet ds = new DataSet();
sda.Fill(ds,"customer");

then use can get the data in row wise or directly assign
the data to the controls through datasource.

i think its enough.If i did any mistake correct me.

Is This Answer Correct ?    13 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is fill method in ado.net?

982


What are different layers of ADO.Net?

1094


What are the different execute methods of Ado.Net?

1027


What is sqlconnection and sqlcommand?

1124


What is maximum pool size in ado.net connection string?

976


What is XML serialization

1062


How to generate a single aggregate?

980


How can we check that some changes have been made to dataset since it was loaded?

971


What is meant by ‘transaction’ in a database and what are the ‘properties of transaction’?

999


What is ole word?

951


Which method is used by command class to execute SQL statements that return single value?

1048


What are the ado.net connection pooling parameters?

983


What is ado net stands for?

970


What is the difference between DataReader and DataSet in ADO.NET?

1165


What is difference between entity framework and ado.net?

930