日期:2014-05-18  浏览次数:20624 次

sqlhelper数据库操作类问题
我看见一个有关数据库操作类的例子。
里边有个添加参数的段落。我没明白是什么意思,麻烦大家帮忙看看

private readonly string RETURNVALUE = "RETURNVALUE";
 cmd.Parameters.Add(
  new SqlParameter(RETURNVALUE,
SqlDbType.Int,4,ParameterDirection.ReturnValue,
false,0,0,string.Empty,DataRowVersion.Default,null));//添加返回参数ReturnValue
哪位能给解释下红色字体代码是什么意思。谢谢

------解决方案--------------------
string parameterName,
SqlDbType dbType,
int size,
ParameterDirection direction,
byte precision,
byte scale,
string sourceColumn,
DataRowVersion sourceVersion,
bool sourceColumnNullMapping,
Object value,
string xmlSchemaCollectionDatabase,
string xmlSchemaCollectionOwningSchema,
string xmlSchemaCollectionName
更具体的参照MSDN
参数
parameterName
要映射的参数的名称。

dbType
SqlDbType 值之一。

size
参数的长度。

direction
ParameterDirection 值之一。

precision
要将 Value 解析为的小数点左右两侧的总位数。

scale
要将 Value 解析为的总小数位数。

sourceColumn
源列的名称。 

sourceVersion
DataRowVersion 值之一。 

sourceColumnNullMapping
如果源列可为空,则为 true;如果不可为空,则为 false。

value
一个 Object,它是 SqlParameter 的值。

xmlSchemaCollectionDatabase
此 XML 实例的架构集合所在的数据库的名称。

xmlSchemaCollectionOwningSchema
包含此 XML 实例的架构集合的关系架构。

xmlSchemaCollectionName
此参数的架构集合的名称。

------解决方案--------------------
C# code

public SqlParameter(
    string parameterName,
    SqlDbType dbType,
    int size,
    ParameterDirection direction,
    bool isNullable,
    byte precision,
    byte scale,
    string sourceColumn,
    DataRowVersion sourceVersion,
    Object value
)