Sequence to connect and retrieve data from database useig
dataset ?

Answer Posted / a.anwar sadat

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

cmd = new SqlCommand("select * from empdetails", con);

da = new SqlDataAdapter(cmd);
ds = new DataSet();
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 ?    13 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is data access pattern?

489


What is the difference between dataset and datatable?

478


Give an example that shows how to execute a stored procedure in ado.net?

559


What are the major challenges in accessing data from a database?

522


Which architecture does Datasets follow?

581






What is datatable in ado.net?

515


Do we use stored procedure in ADO.Net?

567


What is ado.net full form?

548


What is ado.net in vb net?

495


What are all the classes that are available in System.Data Namespace?

548


What are the parameters that control most of connection pooling behaviors?

506


Explain executenonquery?

547


What is ado data control?

518


What are the several execute methods of ado.net?

493


How is it possible to get 2 tables of data at a time by using data reader?

490