Storage procedure uses Daquan

xiaoxiao2021-03-05  24

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 straconn

Set cmd.activeConnection = conn

cmd.commandtext = "{call nono}"

'set RS = cmc.exe or cmd.execute

SET RS = cmd.execute ()

%>

2, a stored procedure for an input parameter

<%

Set conn = server.createObject ("adoDb.connection")

SET cmd = server.createObject ("adodb.command")

StrConn = "DSN = PUBS; UID = SA; PWD"

Conn.open straconn

Set cmd.activeConnection = conn

cmd.commandtext = "{CALL OneInput (?)}"

cmd.parameters.Append Cmd.createParameter ("@ aaa", adINteger, adpaaminput)

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 straconn

Set cmd.activeConnection = conn

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

cmd.parameters.Append Cmd.createParameter ("@ aaa", adINteger, adpaaminput)

CMD ("@ aaa") = 10

cmd.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 straconn

Set 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") = 10

cmd.parameters.Append Cmd.createParameter ("@ BBB", Adinteger, Adparamoutput)

cmd.execute ()

BBB = cmd ("@ bbb")

RRR = CMD ("@ return_value")

%>

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

New Post(0)