Quote address: http://goarer.xicp.net/showlog.asp? Id = 503 Learning to use stored procedures, it is one of the ASP programmers. All large databases support stored procedures, such as Oracle, MS SQL, etc. (but MS Access is not supported, however, parameterized queries can be used in Access). There are many benefits to using the stored procedure, which can encapsulate complex data logic and give full play to the advantages of large database itself. We know that ASP is not suitable for complex data operations, and accesses the database through the OLD DB, because the data needs to be passed between ASP and databases, quite consumption system resources. In fact, if the database only plays a role of data storage, then its function is far from being utilized. For how to create a stored procedure, please refer to the relevant documentation of MS SQL. This article describes how the stored procedure is used in ASP. Simple SQL statement: Select ID, Name, Picture, Time, Duty from Employ We can create a stored procedure: create procedure sp_employasselect ID, name, picture, time, Duty from Employ Go
And SQL statement: SELECT ID, NAME, PICTURE, TIME, DUTY from Employ WHERE ID = 10230 The corresponding stored procedure is: (replaced with alter) Alter Procedure sp_employ @ inId Intasselect ID, Name, Picture, Time , Duty from Employ WHERE ID = @ inIdgo
The case where SQL and stored procedures are in ASP below. First, check out SQL directly: <% DIM conn, strsql, rsset conn = server.createObject ("adoDb.connection") conn.open "DSN = WebData; uid = user; pwd = password" strsql = "select ID , Name, Picture, Time, Duty from Employ "SET RS = conn.execute (strsql)%>
How to perform look Stored Procedure: <% dim Conn, strSQL, rsset Conn = Server.CreateObject ( "ADODB.Connection") Conn.Open "DSN = webData; uid = user; pwd = password" 'make connectionstrSQL = "sp_employ "SET RS = conn.execute (strsql)%>
The Stored Procedure that performs parameters is also quite similar: <% DIM conn, strsql, rs, myintmyint = 1 set conn = server.createObject ("adoDb.connection" conn.open "DSN = WebData; UID = user; PWD = password "strsql =" sp_mystoredprocedure "& myintset = conn.execute (strsql)%>