Method to execute on DataAdapter control for loading Dataset
Which method I can execute on DataAdapter control for loading Dataset with data
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
TulasiPosted Nov 7, 2011, 11:34 PM
use System.Data.SqlClient;
System.Data;
SqlConnection sqlcon=new SqlConnection("connectionstring");
SqlDataAdapter sqldad=new SqlDataAdapter("Select * from Emp ",sqlcon);
Dataset ds=new Datset();
sqldad.fill(ds,"Employee");
Kunal NaikPosted Nov 8, 2011, 1:17 AM
use these 2 namespace in your class,
System.Data;
System.Data.SqlClient;
To execute on DataAdapter for loading DataSet there is Fill() method available. Below is an example to use this method,
string qry = "Select * from TableName";
SqlConnection SqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString);
SqlDataAdapter Da = new SqlDataAdapter(qry,SqlConn);
DataSet ds = new DataSet();
Da.Fill(ds, TableName);
Pravin MorePosted Nov 7, 2011, 11:38 PM
string queryString =
"SELECT CustomerID, CompanyName FROM dbo.Customers";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);
DataSet customers = new DataSet();
adapter.Fill(customers);
Thanks,
Pravin.