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

What are the Features of a dataset

758


How can you identify whether or not any changes are made to the DataSet object since it was last loaded?

647


What are good ado.net object to replace to ado recordset object.

641


How do you merge 2 datasets into the third dataset in a simple manner?

625


How can we perform transactions in .net?

653






What are the advantages and drawbacks of using ado.net?

732


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

637


What are the types of databinding?

638


Which name space is used to get assembly details?

598


What is disconnected architecture in ado.net?

585


Which is faster dataset or datareader?

630


What is a column variable?

571


What is ole in excel?

597


Define Execute Scalar?

644


What is the namespaces being used to access oracle database?

591