Use sqldatareader executereader (string connectionstring, string spname, Params object [] parameter in dnn

Source: Internet
Author: User
Tags dnn
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.