ASP invoke stored procedure source code example
Here's the code: <% @LANGUAGE = "VBSCRIPT" codepage= "936"%> <% Set conn = CreateObject ("ADODB. Connection ") Strcon = "PROVIDER=SQLNCLI; Password=sa; Persist Security info=true; User id=sa;initial catalog=northwind;data source=127.0.0.1 " Conn. Open Strcon
Set cmd = Server.CreateObject ("Adodb.command") With cmd . ActiveConnection = Conn ' Database connection string . CommandText = "test2" ' specifies stored procedure name . CommandType = 4 ' indicates that this is a stored procedure . Prepared = True ' requires that SQL commands be compiled in advance
. Parameters.Append. CreateParameter ("@val1", 3,2,4) . Parameters.Append. CreateParameter ("@val2", 3,2,4) . Execute Response.Write (cmd (0) & "_" & cmd (1)) ' 2 output is out. Set rs =. Execute End With
While not rs.eof Response. Write (RS (1) & "<br/>") Rs.movenext Wend %> |