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
How do you implement locking concept for dataset?
I loaded the dataset with a table of 10 records. One of the records is deleted from the backend, how do you check whether all the 10 records were present while updating the data(which event and steps) and throw the exception 28 can datareader hold data from multiple tables?
What is ole in excel?
Describe briefly an ADO.NET Dataset ?
How can I retrieve two tables of data at a time by using data reader? Data reader read and forward only, how is it possible to get 2 tables of data at a time?
What are the rules to implement connection pooling?
What DataReader class do in ADO.NET ?
Difference between sqlcommand and sqlcommandbuilder?
What we do with the object of ado.net dataset after using it?
How to add a javaScript function in a datagrid?
What are the different layers of ado.net?
What are the major difference between classic ADO and ADO.NET?
Explain what are acid properties?
What is commandbuilder in ado.net?
What is ado oledb and odbc?