SqlBuilder.cs文件,新增AddParam方法, 支持OutPut参数
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
/// <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
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
扫一扫加作者微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网