| C#(CSharp) | VC/C++ | ASP(ASP.NET) | SQL Server | OpenGL | CMM | 网站开发SEO | 数控技术 | 地理信息系统 | WINDOWS操作系统 | |
Method 2 declares the stored procedure, and then explicitly declares
the parameters.
<%
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "data source name", "userid", "password"
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
cmd.CommandText = "sp_test"
cmd.CommandType = adCmdStoredProc
cmd.Parameters.Append cmd.CreateParameter("RetVal", adInteger, _
adParamReturnValue)
cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, _
adParamInput)
" Set value of Param1 of the default collection to 22
cmd("Param1") = 22
cmd.Execute
%>
Calling via method 2
ReturnValue = <% Response.Write cmd(0) %>
Method 3 is probably the most formal way of calling a stored procedure.
It uses the canocial
<%
Set cn = Server.CreateObject("ADODB.Connection")
cn.Open "data source name", "userid", "password"
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = cn
" Define the stored procedure"s inputs and outputs
" Question marks act as placeholders for each parameter for the
" stored procedure
cmd.CommandText = "{?=call sp_test(?)}"
" specify parameter info 1 by 1 in the order of the question marks
" specified when we defined the stored procedure
cmd.Parameters.Append cmd.CreateParameter("RetVal", adInteger, _
adParamReturnValue)
cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, _
adParamInput)
cmd.Parameters("Param1") = 33
cmd.Execute
%>
Calling via method 3
ReturnValue = <% Response.Write cmd("RetVal") %>
注意在上面的例子中,许多的Parameters属性被调用。有的是使用默认值,有些则是使用指定的值。
[VC_VC++_VC.NET] Visual C++实现数字图像增强处理 (5175)
[VC_VC++_VC.NET] 基于Visual C++的Winsock API研究 (3160)
[VC_VC++_VC.NET] VC无模式对话框 (6473)
[VC_VC++_VC.NET] 在VS.NET下创建文件上载控件 (3057)
[VC_VC++_VC.NET] 在Visual C++中使用内联汇编 (3745)
[VC_VC++_VC.NET] window中进程间如何通信 (3461)