The two constructors of sqlhelper. executenonquery have differences in return values.
If sqlhelper. executenonquerystring (connectionstring, string spname, Params object [] parametervalues) is executed, the return value is always unavailable.
If you execute sqlhelper. executenonquery (string connectionstring, commandtype, string commandtext, Params sqlparameter [] commandparameters), you can obtain the returned value.
Ref: http://blog.joycode.com/ghj/archive/2004/04/12/19015.aspx
Notes for using sqlhelper (stored procedures with output and return parameters ):
In sqlhelper, if your stored procedure parameters include output and return parameters. Some functions cannot be used. Specifically:
In sqlhelp, if the input parameters include Params sqlparameter [] commandparameters, it is okay. The problem is that the input parameters include Params object [] parametervalues:
For example:
Public static int executenonquery (string connectionstring, commandtype, string commandtext, Params sqlparameter [] commandparameters.
This
Public static int executenonquery (string connectionstring, string spname, Params object [] parametervalues)
Problems mentioned.
The following is a list of functions with these problems:
Public static int executenonquery (string connectionstring, string spname, Params object [] parametervalues)
Public static int executenonquery (sqlconnection connection, string spname, Params object [] parametervalues)
Public static int executenonquery (sqltransaction transaction, string spname, Params object [] parametervalues)
Public static dataset executedataset (string connectionstring, string spname, Params object [] parametervalues)
Public static dataset executedataset (sqlconnection connection, string spname, Params object [] parametervalues)
Public static dataset executedataset (sqltransaction transaction, string spname, Params object [] parametervalues)
Public static sqldatareader executereader (string connectionstring, string spname, Params object [] parametervalues)
Public static sqldatareader executereader (sqlconnection connection, string spname, Params object [] parametervalues)
Public static sqldatareader executereader (sqltransaction transaction, string spname, Params object [] parametervalues)
Public static object executescalar (string connectionstring, string spname, Params object [] parametervalues)
Public static object executescalar (sqlconnection connection, string spname, Params object [] parametervalues)
Public static object executescalar (sqltransaction transaction, string spname, Params object [] parametervalues)
Public static xmlreader executexmlreader (sqlconnection connection, string spname, Params object [] parametervalues)
Public static xmlreader executexmlreader (sqltransaction transaction, string spname, Params object [] parametervalues)
Public static void filldataset (string connectionstring, string spname,
Dataset dataset, string [] tablenames,
Params object [] parametervalues)
Public static void filldataset (sqlconnection connection, string spname,
Dataset dataset, string [] tablenames,
Params object [] parametervalues)
Public static void filldataset (sqltransaction transaction, string spname,
Dataset dataset, string [] tablenames,
Params object [] parametervalues)
The features of functions are as follows:
Params object [] parametervalues
If you need to use these functions, you will see that you cannot receive the returned Stored Procedure output and returned parameters.
Cause:
In the internal implementation of these functions, he converts object [] parametervalues to sqlparameter [] commandparameters, while commandparameters is a local variable. After leaving this function, these cannot be accessed again. Before return, sqlhelper does not convert the content of commandparameters to parametervalues. Therefore, you cannot access the returned or output parameter values.