如何调用在数据库查询单值的存储过程

怎么调用在数据库查询单值的存储过程
写了个公共方法
public static object SelectDanZhi(string proname,CommandType type,params SqlParameter [] pp) {
            using (SqlConnection con=new SqlConnection(constr))
            {
                SqlCommand cmd = new SqlCommand();
                PropareCommand(con, cmd, type, proname, pp);
                return cmd.ExecuteScalar();
            }
        }
数据访问
 public static string SelectDan(int id) {
          string pro = "sp_tang3";
          SqlParameter[] pp = { 
                              new SqlParameter("@id",id),
                              new SqlParameter("@name",SqlDbType.NVarChar),
                            
                              };
          return Convert.ToString(Dbhelp.SelectDanZhi(pro,CommandType.StoredProcedure,pp));
      }
在数据库访问的时候该怎么写才正确呢?
------解决思路----------------------
你现在碰到什么问题?
------解决思路----------------------
引用:
报错说缺少@name参数,这是我写的存储过程
create proc sp_tang3
@id int,
@name nvarchar(20) output
as
select @name=aname from tablea where aid=@id
go

new SqlParameter("@name", ParameterDirection.Output)
------解决思路----------------------
引用:
运行webservice 出现
This XML file does not appear to have any style information associated with it. The document tree is shown below.
并没有显示出值,什么原因呢

试试
SqlParameter[] pp = { 
                               new SqlParameter("@id",id),
                               new SqlParameter("@name",SqlDbType.NVarChar),
                             
                               };
pp[1].Direction = ParameterDirection.Output;
------解决思路----------------------
new SqlParameter里面的参数名不要加@
------解决思路----------------------
引用:
还是不行!
System.InvalidOperationException: String[1]: Size 属性具有无效大小值 0。
还是参数的问题吗

你给new SqlParameter("@name",SqlDbType.NVarChar)分配个大小
你存储过程分配多少就是多少,比如new SqlParameter("@name",SqlDbType.NVarChar, 100)之类的