In the development of the B/S structure, we can write some business rules or complex queries in DBMS, and then call the ADO object in ASP to complete the traditional function of the original C/S structure.
The following discussion is an instance tutorial articles related to the MSSQL database view and storage procedure related to the MSSQL database view. The
In general MIS applications, there will be a large number of reports. At this time, we can write corresponding views or storage procedures in the background database, and use ASP to call the report through ADO calls. Let's use an example to illustrate the corresponding operation process.
1. Create ODBC DSN file
Before creating a database script, a way to provide ADO positioning, logo and communication with databases must be provided. The database driver uses the Data Source name (DSN) positioning and identifying a specific ODBC compatible database to pass the information from the web application to the database.
2. Call the database view
The first step to access the database information is to connect to the source of the database. Ado provides Connection objects that can use the object to establish and manage the connection between the application and the ODBC database.
| The following is the reference content: <% Set dataconn = server.createObject (adodb.connection) ' Dataconn.open dsn = sinotrans; server = app_server; Uid = sa; pwd =; app = microsoft (R) Developer Studio; wsid = app_server; regional = yes Set CMDTEMP = Server.createObject (Adodb.Command) 'Create command object Set rst = server.createObject (Adodb.oldSet) ' CMDTEMP.CommandText = Customers cmdtemp.commandtype = 2 Set CMDTEMP.ActiveConnection = DataConn. RST.open CMDTEMP,, 1, 3 'Generate query results %> |
At this time, CUSTOMERS is a view that query data from the view that the method of querying the data from the base table is the same.
3. Call the database storage procedure
| The following is the reference content: <% Set dataconn = server.createObject (adodb.connection) ' Dataconn.open dsn = sinotrans; server = app_server; uID = SA; Pwd =; app = microsoft (R) Developer Studio; wsid = app_server; regional = yes Set CMDTEMP = Server.createObject (Adodb.Command) 'Create command object Set rst = server.createObject (Adodb.oldSet) ' cmdtemp.commandtext = dbo.pd_test 'Storage procedure name cmdtemp.commandtype = 4 'command category is 4, indicating as a storage procedure Set CMDTEMP.ActiveConnection = DataConn Set tmpparam = CMDTEMP.CreateParameter (RETURN VALUE, 3, 4, 4) cmdtemp.parameters.append tmpparam Set tmpparam = cmdtemp.createparameter (@Begindate, 135, 1, 16, RIQI) 'Create an input parameter object cmdtemp.parameters.append tmpparam RST.open CMDTEMP,, 1, 3 'Generate query results %> |
The storage procedure called here is PD_TEST. This is the standard method provided in ADO, but there is a problem that when there are more than two select statements in the storage procedure, but it is not possible to execute at the same time from logic. It will prompt that there are too many SELEC statements in the storage procedure. The solution is to directly use the Execute method of the Connection object of the Ado to perform the storage procedure directly, as follows::
| The following is the reference content: <% Set dataconn = server.createObject (adodb.connection) ' Dataconn.open dsn = sinotrans; server = app_server; uID = SA; pwd =; App = microsoft (R) Developer Studio; wsid = app_server; regional = yes SS = Execute dbo.pd_teest & '& riqi1 &' Set rs = dataconn.execute (ss) %> |
For more information about ASP and ADO, see Microsoft Activex Data Objects (ADO) and Active Server Pages (ASP).
5. End language
In the development of the B/S structure, we can write some business rules or complex queries in DBMS, and then call the ADO object in ASP to complete the traditional function of the original C/S structure. This page website: http://www.vevb.com/biancheng/2018091421698.shtml, if you help you welcome to collect or reprint the URL, please visit http://www.vevb.com again!