create proc a
select * from b  (没有where条件)C# 读取 存储过程 返回的结果集 

解决方案 »

  1.   

     using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection())
                {
                    conn.ConnectionString = ".........";
                    using (System.Data.SqlClient.SqlCommand command = conn.CreateCommand())
                    {
                        command.CommandText = "a";
                        using(System.Data.SqlClient.SqlDataAdapter adp=new System.Data.SqlClient.SqlDataAdapter(command))
                        {
                            System.Data.DataSet ds = new System.Data.DataSet();
                            adp.Fill(ds, "a");
                        }
                    }
                    conn.Close();
                }
      

  2.   

    和读 SQL string 一样啊
      还是可以返回 datareader 或是 dataset
      

  3.   

    C#里根据存储过程的结果,返回一个DataSet或者DataReader都可以不明白楼主有何深意
      

  4.   

    就想一般的  T-SQL  语句一样得到结果集啊
      

  5.   

    俺 不知道 net框架是如何设计得到结果集的
    没有研究过啊 有人研究过这个东东?(如何得到 存储过程的结果集啊)
      

  6.   

    你的这个:create proc a 
    select * from b  (没有where条件) 
    与直接的select * from b  楼主觉得有什么区别
      

  7.   

    楼主的意思吗?-----很有挑战性的问题 
    执行存储过程.就可以得到结果呀.和普通的SQL没有区别吧
      

  8.   

    qq137523133      2008年06月10日 13点03分25秒 说:
        您在吗???amandag      2008年06月10日 13点07分11秒 说:
        你打算取到哪里?qq137523133      2008年06月10日 13点08分47秒 说:
        或者别的里也可以amandag      2008年06月10日 13点08分52秒 说:
        要用存储过程?qq137523133      2008年06月10日 13点09分01秒 说:
        对amandag      2008年06月10日 13点09分21秒 说:
        打算是web程序里用还是winform应用程序里用qq137523133      2008年06月10日 13点09分37秒 说:
        如果要存储过程取的话 那只是一条qq137523133      2008年06月10日 13点09分44秒 说:
        webamandag      2008年06月10日 13点10分08秒 说:
        不会的,返回的肯定是多条,你用的是VS2005么?qq137523133      2008年06月10日 13点10分41秒 说:
        2008 2005 混用amandag      2008年06月10日 13点11分00秒 说:
        那我2005给你写个例子qq137523133      2008年06月10日 13点11分19秒 说:
        好的 谢谢了qq137523133      2008年06月10日 13点11分24秒 说:
        好的 谢谢了amandag      2008年06月10日 13点14分22秒 说:
        先创建存储过程
        Create proc GetAuthors
        as
        select * from authors
        goamandag      2008年06月10日 13点15分50秒 说:
        using System.Data.SqlClient;
        public partial class BB : System.Web.UI.Page
        {
        private void BindGrid()
        {
        //这里替换成你的连接字符串
        SqlConnection cn = new SqlConnection(@"server=.\SQLExpress;uid=sa;pwd=password;database=pubs");
        //GetAuthors是你的存储过程名字
        SqlDataAdapter da = new SqlDataAdapter("GetAuthors", cn);
        //指明查询的类型为存储过程,很重要
        da.SelectCommand.CommandType = CommandType.StoredProcedure;
        DataSet ds = new DataSet();
        cn.Open();
        da.Fill(ds);
        cn.Close();
        GridView1.DataSource = ds;
        GridView1.DataBind();
        }    protected void Page_Load(object sender, System.EventArgs e)
        {
        if (!IsPostBack)
        {
        BindGrid();
        }
        }
        }amandag      2008年06月10日 13点16分07秒 说:
        假设你的页面上有一个GridView控件qq137523133      2008年06月10日 13点16分41秒 说:
        额```这么简单...amandag      2008年06月10日 13点17分07秒 说:
        hehe,所以下面有人怀疑你倒分啊qq137523133      2008年06月10日 13点18分48秒 说:
        麻烦您了amandag      2008年06月10日 13点19分16秒 说:
        不麻烦,最重要的是要使用参数,不要拼接SQL语句qq137523133      2008年06月10日 13点19分38秒 说:
        您有QQ 或者MSN吗呵呵 ,,,有太简单了 自己也吓一跳 没办法 在简单也是问题