How to call a stored procedure with output parameters in asp
Source: Internet
Author: User
This is my stored procedure create proc Hz @ count2 bigint output, @ minsl varchar, @ maxsl varchar as create table # TMP (qqno bigint, [Check] tinyint, sumsl varchar) create Table # tmp1 (qqno bigint, friendqqno bigint, addtime datetime, [Check] tinyint, sumsl varchar) insert into # TMP select qqno, [Check], count (*) as count1 from friendtable group by qqno, [Check] order by qqno insert into # tmp1 select # TMP. qqno, friendqqno, addtim E, # TMP. [Check], sumsl from # TMP left join friendtable on # TMP. qqno = friendtable. qqno where sumsl >=@ minsl and sumsl <= @ maxsl select @ count2 = count (*) from # tmp1 go set o_command = server in ASP. createobject ("ADODB. command ") set o_command.activeconnection = conn1 o_command.commandtext =" HZ "o_command.commandtype = 4 set o_prm = o_command.parameters o_prm.append partition (" @ count2 ", adinteger, adpara Moutput) o_prm.append partition ("@ minsl", advarchar, adparaminput, Friends) o_prm.append partition ("@ maxsl", advarchar, adparaminput, friends1) o_command.execute () count2 = cmd ("@ count2") Why is this error? Microsoft VBScript compiler error: '800a03f6 'missing 'end'/IISHelp/common/500-100.asp, row 242 Microsoft ole db provider for ODBC drivers error '80040e14' [Microsoft] [odbc SQL Server Driver] [SQL Server] process 'hz' requires parameter '@ minsl ', however, this parameter is not provided. /Friendtable1.asp, row 65
There should be declare o_prm.Append partition ("@ count2", adinteger, adParamOutput, 4) o_prm.Append partition ("@ minsl", advarchar, adParamInput, 50) o_prm.Append partition ("@ maxsl ", advarchar, adParamInput, 50) Maybe adinteger and adParamOutput are not assigned values. Some constants such as adinteger and adParamOutput in VB have values, but in ASP, you need to set its own value to admo-spstoredproc = 4 adParamReturnValue = 4 adParaminput = 1 adParamOutput = 2 adInteger = 3 adVarChar = 200. All right, try it, count2 = minsl = maxsl = set rs1_conn.exe cute ("hz" & count2 & "','" & minsl &"', '"& maxsl &"' ") rs (" count2 ") can be output to add Try the adovbs. inc file in c: \ Program Files \ common files \ System \ ADO. If not, replace the constants adinteger with the original values! Createparameter ([name], [type], [direction], [size], [value]) creates a new parameter used by the command object. Name is the name of the new parameter. Type is the data type of this parameter. You can use any data type shown in the following table: adbigint 20 8-byte signed integer adbinary 128 binary value adboolean 11 Boolean value adbstr 8 null-interrupt string (UNICODE) adchar 129 string value adcurrency 6 currency value addate 7 Date value addbdate 133 date value (yyyymmdd) addbtime 134 time value (hhmmss) addbtimestamp 135 date time value (yyyymmddhhmmss) addecimal 14 has a fixed precision and range of extended numeric type. Addouble 5 double precision floating point value adempty 0 null value aderror 10 32 bit error code adguid 72 the world's only flag code adidispatch 9 points to an OLE object idispatch pointer adinteger 3 4 byte signed integer adiunknown 13 points to OLE object iunkown pointer adlongvarbinary 205 long binary value adlongvarchar 201 long string value adlongvarwchar 203 long null-interrupt string value adnumeric 131 has fixed precision and range extended numeric type. Adsingle 4 single precision floating point value adsmallint 2 2 byte signed integer adtinyint 16 1 byte signed integer adunsignedbigint 21 8 byte unsigned integer adunsignedint 19 4 byte unsignedsmallint 18 2 byte unsigned integer adunsignedtinyint 17 1 byte unsigned integer aduserdefined 132 undefined variable advarbinary 204 binary value advarchar 200 string value advariant 12 OLE Automatic Variable advarwchar 202 null-interrupt Unicode string adwchar 130 null-interrupt Unicode string ction determined parameters are input parameters, return values of output parameters or stored procedures. The following table describes all the direction values you can use: constant value description adparami Nput 1 input parameter (default value) adparamoutput 2 output parameter adparaminputoutput 3 input/output parameter adparamreturnvalue 4 return value size is the maximum length of the parameter, in bytes or characters. Value is the parameter value. For more information about this method, refer to passing parameters to the stored procedure. If a single SQL statement is not used in the stored procedure, the advantages of calling the stored procedure are not displayed! For example, you can query a BBS by author or topic! The stored procedure can be set up as follows: the keyword parameter is the keyword, And the choose is the method for selecting the query. Create procedure [DBO]. [dt_bbs] @ keyword varchar (20) = NULL, @ choose Int = NULL as if choose = 1 select * from BBS where name like @ keyword else select * from BBS where subject like @ keyword return go so we only need to set the parameters when calling the Stored Procedure pass it over, instead of writing a program in ASP, use the first method: Set rs = server. createobject ("ADODB. recordset ") SQL =" Exec dt_bbs '"& keyword &"', "& choose &" Rs. open SQL, Conn, 1, 1
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