SqlBuilder.cs文件,新增AddParam方法, 支持OutPut参数
作者:C/S框架网  发布日期:2013-09-11 16:11:44
  SqlBuilder.cs文件,新增AddParam方法, 支持OutPut参数



C# Code:

/// <summary>
/// 增加参数
/// </summary>
/// <param name="parameterName">参数名称,带@符号</param>
/// <param name="sqlDbType">SqlDbType类型</param>
/// <param name="value"></param>
/// <param name="direction">输入/输出类型</param>
public void AddParam(string parameterName, DbType dbType, int size,
object value, ParameterDirection direction)
{
   string symbol = DataProvider.DBCreator.ParamSymboName;
   DbParameter p = DataProvider.DBCreator.CreateParameter();
   p.ParameterName = (_AddParamHeader ? symbol : "") parameterName;
   p.DbType = dbType;
   p.Size = size;
   p.Value = value;
   p.Direction = direction;
   int i = _cmd.Parameters.Add(p);
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898


使用方法:

C# Code:

public bool TestOutputParameter(ref string outputValue)
{
   SqlProcedure sp = SqlBuilder.BuildSqlProcedure("usp_TestOutputParameter");
   sp.AddParam("@TestDate", DbType.DateTime, 8, null, ParameterDirection.Output);
   DataProvider.Instance.ExecuteNoQuery(_Loginer.DBName, sp.SqlCommand);
   //取参数值
   outputValue = ConvertEx.ToString(sp.SqlCommand.Parameters["@TestDate"].Value);
   return true;
}

//来源:C/S框架网(www.csframework.com) QQ:1980854898


上一篇 下一篇