Method to execute on DataAdapter control for loading Dataset
Which method I can execute on DataAdapter control for loading Dataset with data
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
TulasiRank #2,544 · 549 reputationPosted Nov 7, 2011, 6:34 PM EST
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");
Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 7, 2011, 6:38 PM EST
string queryString =
"SELECT CustomerID, CompanyName FROM dbo.Customers";
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection);
DataSet customers = new DataSet();
adapter.Fill(customers);
Thanks,
Pravin.
Kunal Naik163 reputationPosted Nov 7, 2011, 8:17 PM EST
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);