Reputation: 19
This is my class code. I want to return the dataset from the procedure _return() I want to return this to another form where I called the procedure. What return type should I use? How to implement it?
public class Class1
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS2005;AttachDbFilename='C:\Users\krish\Documents\Visual Studio 2005\WebSites\TRS\App_Data\Database.mdf';Integrated Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
public void _return(String qry)
{
con.Open();
da = new SqlDataAdapter(qry, con);
da.Fill(ds, "details");
con.Close();
}
}
Upvotes: 1
Views: 21365
Reputation: 52241
You can mention function return type DataSet
and simply return that DataSet
public DataSet _return(String qry)
{
con.Open();
da = new SqlDataAdapter(qry, con);
da.Fill(ds, "details");
con.Close();
return ds;
}
Upvotes: 9