【问题标题】:how to return dataset in c#.net如何在 c#.net 中返回数据集
【发布时间】:2011-10-02 14:41:14
【问题描述】:

这是我的课程代码。我想从过程 _return() 返回数据集 我想将此返回到我调用该过程的另一种形式。 我应该使用什么返回类型?如何实现?

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();
    }
}

【问题讨论】:

    标签: c# .net asp.net dataset return


    【解决方案1】:

    您可以提及函数返回类型 DataSet 并简单地返回 DataSet

    public DataSet _return(String qry)
    {
        con.Open();
        da = new SqlDataAdapter(qry, con);
        da.Fill(ds, "details");
        con.Close();
        return ds;
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-16
      • 1970-01-01
      • 1970-01-01
      • 2011-02-11
      相关资源
      最近更新 更多