What is sequence of code in retrieving data from database ?

Answer Posted / payal

//In this answer there is sqlserver
/*i write this code in vb.net with windows applications and
use sql server provider*/
//first need namespace

system.data.sqlclient
//need connection,command,connection string

dim sqlcmd as sqlcommand
dim sqlcon as sqlconnection
dom da as sqldataadaptor
dim ds as dataset
dim constr as sting="user
password=sss;datasource=sds;initial catalog=fgf"

/*connection string give all details about database
connection initial catalog means data base name and data
source is sqlserver name,user id and password also*/

//open connection and pass connection string

sqlcon=new sqlconnection(constr)
sqlcon.open()

//create new object of command with new keyword

sqlcmd=new sqlcommand("select * from tablename",sqlcon)

/*data adapter is mediater between the data base and data
set because dataset is work in disconneted mode.*/

da=new sqldataadaptor(sqlcmd)

/*data adapter fetch query to data base and get answer and
fil the dataset using fill*/

da.fill(ds)

/*there is datagird which i use for display data on
form.data from dataset i use this bind to datagrid*/

datagird.datasource=ds.tables("table name")

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference in record set and dataset?

493


differences between ADO and ADO.NET

574


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

557


What is data control techniques?

514


Define the data provider classes that is supported by ado.net?

523






How do you update database through dataset?

544


What is difference between sqldatareader and sqldataadapter?

490


What is fill method in ado.net?

543


If a table contains 20000 records. In a page at each time 100 records to be displayed.

524


Name which operations can you not perform on an ado.net dataset?

490


Compare Data Reader & Dataset in ado.net?

550


What is basic use of data view?

515


What is the use of ADO.NET and XML web services?

596


What are the data providers in ADO.NET framework?

594


What is ole in vb?

514