我SQL2005 写了一个存贮过程 
在SQL 2005中能查到结果但在 .net 中却得到null期盼 你的解答!!! 谢谢见下面代码:
/** SQLHelper
  *  Greate Version : 1.0.0.2
  *  Greate By : Shasa
  *  Greate On : 2010-12-05
  * */    class SQLHelper
    {
        //TODO  修改为可以从数据库读出数据
        static string connStr = null;        public SQLHelper()
        {
            connStr = Properties.Settings.Default.dataconn;
        }
  /// <summary>
        /// 读取原始数据,返回一个DataTable。
        /// </summary>
        /// <param name="sqltext">SQL语句</param>
        /// <returns></returns>
        public DataTable testTable(string sqltext)
        {   /**  读取原始数据
             *  1 执行sqltext语句,读取原始数据
             *  2 返回一个DataTable。
             * 
             * **/            //TODO  这里没有得到数据   TIP 可能存贮过程的调用方法不对
            DataTable table = new DataTable();
            SqlDataAdapter dt = new SqlDataAdapter(sqltext, connStr);
            dt.Fill(table);
            return table;
        }
}//调用
        SQLHelper sqlhelper = new SQLHelper();
        DataTable weaterData = new DataTable();      
        double cateP = 0.0, cateN = 0.0;
        string sqltext = null;        public double temperSunInfo()
        {
           
            sqltext = "EXECUTE  UP_GROUP_BY_ATTRI_WEA  '晴'";
            weaterData = sqlhelper.testTable(sqltext);                     cateP = (double)weaterData.Compute("Count(category)", "category = 'P'");  // 在里提示错误
            cateN = (double)weaterData.Compute("Count(category)", "category = 'N'");            return  cateN+cateArr;
           
        }

解决方案 »

  1.   

    存储过程
    using(SqlConnection sqlconn = new SqlConnection(conn))
    {
           SqlCommand cmd = new SqlCommand("",conn);
           cmd.CommandType = CommandType.StoredProcedure;
            IDataParameter[] parameters = {
                    new SqlParameter("@Name", SqlDbType.NVarChar,15)   
                };
            parameters[0].Value = "";    
            cmd.Parameters.Add(parameters[0]);
           SqlDataAdapter dp = new SqlDataAdapter(cmd);
           DataSet ds = new DataSet();
           dp.Fill(ds);}