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
Which components of a data provider is used to retrieve, insert, delete, or modify data in a data source?
What is the namespaces being used to access oracle database?
What does adodb stand for?
What is defaultview in datatable?
Explain which name space is used to get assembly details?
If we are not returning any records from the database, which method is to be used?
What is linq and entity framework?
What is a string variable?
What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?
Does dapper use ado.net?
What is untyped dataset?
Which method in OLEDBAdapter is used to populate dataset with records?
How can you add or remove rows from the datatable object of dataset?
What is difference between datatable and dataset?
differences between ADO and ADO.NET