Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


Write steps of retrieving data using ado.net ?

Answers were Sorted based on User's Feedback



Write steps of retrieving data using ado.net ?..

Answer / 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

Write steps of retrieving data using ado.net ?..

Answer / sudheer lakkireddy

Take a gridview control in ur design
add
using system.data.sqlclient;
using.system.data;
// give a connection string to database

sqlconnection con= new sqlconnection("conn");

//in button click event write following

sqldataadapter da=new sqldataadapter("select * from
(tablename)",con);
dataset ds=new dataset();
da.fill(ds,"tablename");
gridview1.datasource=ds;
gridview1.datamember="tablename";
gridview1.databind();

try out this

Is This Answer Correct ?    4 Yes 1 No

Write steps of retrieving data using ado.net ?..

Answer / ashokdahiya

We can retrieve data in following ways in .net
1st we have to create connection object through sqlclient or
oledb provider.then open connection
2nd We can choose datacommands or data adapter(by sqlclint
or oledb dataprovider
system.data
system.data.oledb //to oledb adapter
system.data.sqlclient //to sqlclient adapter
dim con as new connection
con=("provider=oledb;initial
catalog=databasename;userid=sa;paswd=;data source=servername;")
con.open
dim query as string="select* from tabel"
dim ad as new oledb.oledbprovider(query,con)
dim ds as dataset
ad.fill(ds)
dim dt as new datatable()
dt=ds.table(0) //is for ist tabel
dim dr() as datarow //it is array becouse it contain all
rows and coulmn for table
dr()=dt.select("") //blank for all coulmns and rows
for i as integer=0 to dr.length-1.tostring
if dr(i)("empid")=textbox.text then
listbox1.items.add(dr(i)("firstname")&
dr(i)("lastname")& dr(i)("email"))
//it will add records of perticular row that matches to the
textbox text in listbox.suppose u enter a001 if it is valide
id then the all records of a001 r added into the list box.//
next

it will work fine.try thanks

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More ADO.NET Interview Questions

What is the difference between Response.Expires and Reponse.ExpiresAbsolute?

0 Answers  


What are the pre-requisites for connection pooling?

0 Answers  


What is the difference between oledb sql server and oledbdotnet provider?

0 Answers  


Some important instruction regarding ADO.NET connection string ?

0 Answers   NA,


What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

0 Answers  






What are the objects of ado.net?

0 Answers  


How to enable and disable connection pooling?

0 Answers  


What is the difference between the clone() and copy() methods of the dataset class?

0 Answers  


How do you implement locking concept for dataset?

0 Answers  


What are all the different authentication techniques used to connect to MS SQL Server?

0 Answers  


What are the advantages of using datalist?

0 Answers  


What are the different namespaces used in the project to connect the database?

3 Answers  


Categories