如题

解决方案 »

  1.   

    create procedure sp_output
    @out int=1 output
    as
    set @out=22
    SqlConnection conn=new SqlConnection(@"server=blackant\db;database=master;uid=sa;pwd=不告诉你");
    SqlCommand comm=new SqlCommand("sp_output",conn);
    comm.CommandType=CommandType.StoredProcedure;
    SqlParameter param=new SqlParameter("@out",SqlDbType.Int);param.Direction=ParameterDirection.Output;
    comm.Parameters.Add(param);
    conn.Open();comm.ExecuteNonQuery();
    conn.Close();
    Console.WriteLine("Value:{0}",param.Value);
      

  2.   

    谢谢您给我的指导,我想问的是,有多个输入参数的时候,我的程序怎么写,我的添加存储过程参数的方法在一个工厂模式的类里面,我是通过数组传递的如:
        protected IDataParameter[] Add(string[] InputPara, DbType[] type, object[] InputValue,ParameterDirection[] direction)
        {
            IDataParameter[] paraList = Factory.ReParaList(InputPara.Length);
            for (int i = 0; i < InputPara.Length; i++)
            {
                IDataParameter IPara = Factory.RePara();
                IPara.DbType = type[i];
                IPara.ParameterName = InputPara[i];
                IPara.Value = InputValue[i];
                paraList[i] = IPara;
                if (direction[i] == ParameterDirection.Output)
                {
                    不知道怎么写
                }
            }        return paraList;
        }怎么在一个方法又返回参数数组,还可以得到输出参数呢??