[英]how to return dataset in c#.net
This is my class code.这是我的 class 代码。 I want to return the dataset from the procedure _return() I want to return this to another form where I called the procedure.我想从过程 _return() 返回数据集 我想将它返回到我调用该过程的另一种形式。 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();
}
}
You can mention function return type DataSet
and simply return that DataSet
您可以提及 function 返回类型DataSet
并简单地返回该DataSet
public DataSet _return(String qry)
{
con.Open();
da = new SqlDataAdapter(qry, con);
da.Fill(ds, "details");
con.Close();
return ds;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.