Several methods of calling stored procedures in ASP

zhaozj2021-02-12  141

1. Call the stored procedure without parameters <% set conn = server.createObject ("adodb.connection") set cmd = server.createObject ("adoDb.command") strconn = "DSN = PUBS; UID = SA; PWD"

Conn.open strconnset cmd.activeconnection = conn

cmd.commandtext = "{call nono}"

'set = cmc.exe or cmd.execute

SET RS = cmd.execute ()

%>

2, a stored process of an input <% set conn = server.createObject ("adoDb.connection") set cmd = server.createObject ("adoDb.command") strconn = "DSN = PUBS; UID = SA; PWD"

Conn.open strconnset cmd.activeconnection = conn

CMD.Commandtext = "{call oneInput (?)}" cmd.parameters.Append cmd.createParameter ("@ aaa", adINteger, adhangaminput) cmd ("@ aaa") = 100

cmd.execute ()

%>

3, an input parameter and an output parameter <% set conn = server.createObject ("adoDb.connection") set cmd = server.createObject ("AdoDb.command") strconn = "DSN = PUBS; UID = SA; PWD "

Conn.open strconnset cmd.activeconnection = conn

cmd.commandtext = "{CALL Oneinout (?,?)}" cmd.parameters.append cmd.createparameter ("@ aaa", adINteger, adhangaminput) cmd ("@ aaa") = 10cmd.parameters.Append cmd.createParameter "@BBB", Adinteger, ADPARAMOUTPUT)

cmd.execute ()

BBB = CMD ("@ bbb")%>

4, an input parameter, an output parameter, and a return value <% set conn = server.createObject ("adodb.connection") set cmd = server.createObject ("adoDb.command") strconn = "DSN = Pubs; UID = SA; PWD "

Conn.open strconnset cmd.activeconnection = conn

cmd.commandtext = "{? = CALL ANDRETURN (?,?)}"

cmd.Parameters.Append cmd.CreateParameter ( "@ return_value", adInteger, adParamReturnvalue) cmd.Parameters.Append cmd.CreateParameter ( "@ aaa", adInteger, adParamInput) cmd ( "@ aaa") = 10cmd.Parameters.Append cmd .CreateParameter ("@ bbb", adINteger, adparamoutput) cmd.execute ()

BBB = cmd ("@ bbb") rrr = cmd ("@ Return_Value")%>

转载请注明原文地址:https://www.9cbs.com/read-6706.html

New Post(0)