Write steps of retrieving data using ado.net ?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is disconnected architecture in ado.net?

711


How can we add/remove row's in "datatable" object of "dataset"?

752


What is the difference between OLEDB Provider and SqlClient?

709


How to connect and retrieve data from database using dataset

728


What is ado connection?

690


How do I delete a row from a DataTable?

764


Explain About ado.net components/objects. Usage of data adapters and tell the steps to retrieve data.

776


What is ado.net components?

677


What is the namespaces being used to access oracle database?

726


What are advantages of microsoft-provided data provider classes in ado.net?

755


What is difference between datareader and dataadapter?

770


What are the advantages of using datalist?

688


Does entity framework use ado.net?

706


What is Serialization in .NET? what are the types of Serialization?

753


I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?

756