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
What is the difference between a datareader and a dataset?
What are the uses of Stored Procedure?
What are the Data providers in ADO.Net?
What are the different row versions available in table?
What is namespace in ado.net?
How to bind the controls(best practice) comboboxes to the data in the dataset?
What is the return type of executescalar?
What is the default provider in ado.net?
What DataReader class do in ADO.NET ?
What is difference between executequery and executeupdate?
What are the advantages using ado.net?
What does executequery return?
Which components of a data provider is used to retrieve, insert, delete, or modify data in a data source?
What is two way data binding android?
What is the difference between the clone() and copy() methods of the dataset class?