The stored procedure is stored in SQL Server. Because no stored procedure is used for tofu
SQL2K is used. It is estimated that the same should be true in Oracle. You are welcome to discuss this issue with bean curd.
We know that there is an output parameter in the stored procedure. It can pass parameters in different stored procedures.
Pay attention to the following situations:
The OUTPUT variable must be defined when the table is created and used. The parameter name and variable name do not have to match, but the data type and parameter location must match
Create a simple Stored Procedure
Create procedure test
(@ Subject Varchar (15) Output)
AS
Select @ subject = tofu is made of excellent products
GO
But how can we get the return parameter? Finally, I was inspired by SQL AnaLyzer,
DECLARE @ aa Varchar (10)
Execute test @ aa output
Select aa = @ aa
Based on this, we can use the multi-statement processing function of ADO + in Asp. Net to implement our ideas. Finally, through SQLDataReader
The complete program is as follows.
<% @ Import Namespace = "System. IO" %>
<% @ Import Namespace = "System. Data" %>
<% @ Import Namespace = "System. Data. SQL" %>
<Script language = "C #" runat = server>
Protected void Page_Load (Object Src, EventArgs E ){
SQLDataReader dbRead;
SQLCommand dbComm;
String strSQL;
String strConn;
SQLConnection conn;
Hashtable Cfg = new Hashtable ();
Cfg = (Hashtable) Context. GetConfig ("appsettings ");
StrConn = Cfg ["Conn"]. ToString ();
Conn = new SQLConnection (strConn );
StrSQL = "DECLARE @ aa Varchar (10) execute test @ aa outputselect aa = @ aa ";
DbComm = new SQLCommand (strSQL, conn );
DbComm. ActiveConnection. Open ();
DbComm. Execute (out dbRead );
DbRead. Read ();
Showmsg. Text = dbRead ["aa"]. ToString ();
}
</Script>
<Html>
<Head>
<Title> test the Stored Procedure </title>
</Head>
<Body>
<Asp: Label id = showmsg runat = server/>
</Body>
</Html>
In fact, the output parameter is rarely used in the actual application, and the bean curd is generally used in this way:
The content of the stored procedure is as follows:
Create procedure test
AS
Select @ subject = tofu is made of excellent products
Select aa = @ subject
GO
The stored procedure returns a record set using the Select statement at the end of the stored procedure. Then we can set the Stored Procedure
As a select statement, the SQL statement of asp. Net becomes
StrSQL = "test ";
Other content changes, and the same effect can be obtained.