Sequence to connect and retrieve data from database useig
dataset ?

Answer Posted / reply2anwar

public SqlConnection con = new SqlConnection("server=anwar;uid=sa; pwd=s;database=Employee;");
public SqlCommand cmd;
public SqlDataAdapter da;

private void RetriveData()
{
cmd = new SqlCommand("select * from empdetails", con)
DataSet ds = new DataSet();
using(da = new SqlDataAdapter(cmd))
{

da.Fill(ds, "empdetails");
foreach(DataRow dr in ds.Tables["empdetails"].Rows)
{
txtempname.Text = dr["name"].ToString();
txtdob.Text = dr["dob"].ToString();
txtstreetname.Text = dr["street"].ToString();
} // foreach
}
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how Sequence to connect and retrieve data from database using dataset?

747


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

550


Does dapper use ado.net?

591


Which object holds only data and does not interact with data source?

493


Can datareader hold data from multiple tables?

672






Define executenonquery?

515


Explain the two fundamental objects in ado.net?

497


What are the types of databinding?

549


What are the different layers of ado.net?

514


Can we create Synonymns in MS Acess,My Sql Server,Sql Server? But iam we can create in oracle!

1633


Explain the difference in an abstract class and an interface?

497


How can I retrieve two tables of data at a time by using data reader?

507


How to find the given query is optimised one or not?

501


What is the difference between typed and untyped dataset?

504


Explain what are the steps to connect to a database?

488