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
What is the use of connection object in ado.net?
What is the difference between executenonquery () and executescalar ()?
Can we connect two dataadapters to same data source using single connection at same time?
What are the pre-requisites for connection pooling?
What is DataReader Object?
What is aggregate root?
how Sequence to connect and retrieve data from database using dataset?
What are dcl commands?
Does executenonquery return a value?
What are the advantages using ado.net?
What are datareaders?
How does entity framework work?
How to check if a datareader is closed or opened? IsClosed()
Do you use stored procedure in ado.net?
What are the major challenges in accessing data from a database?