An example of a disconnected database connection

Source: Internet
Author: User
A key condition for using a disconnected Recordset is to use a temporary table on the client, that is
Specify Rs. CursorLocation = adUseClient or 3. The following is a complete
Example:
Demo-1.asp (online demo: http://www.aspcn.com/demo/demo-1.asp)
------------------------------------------------------------
<% @ Language = VBScript %>
<%
'#-------------------------------------------------------------------
---------
'# Program Description: shows how to use a disconnected record set.
'# Program design: Yahao
'#-------------------------------------------------------------------
---------
On Error Resume Next
Dim adoConn, adoRs, SQLCmd, ConnectString
'#--------------------------------------------------------------------
---------
'# Use the DSN-less method of SQL Server to connect to the database
'#--------------------------------------------------------------------
---------
ConnectString = "Driver = {SQL Server };"&_
"Server = (local );"&_
"Database = abc ;"&_
"Uid = sa ;"&_
"Pwd = 123"
'#--------------------------------------------------------------------
---------
'# Create an object instance and initiate a Connection)
'#--------------------------------------------------------------------
---------
Set adoConn = Server. CreateObject ("ADODB. Connection ")
Set adoRs = Server. CreateObject ("ADODB. Recordset ")
AdoConn. Open ConnectString
SQLCmd = "Select * from bbs_user where LTrim (RTrim (id) = 'w3org '"
'#--------------------------------------------------------------------
---------
'# Use the temporary client table to open and save the record set. The key is!
'# The client is the host that runs ASP Programs, relative to the database server
'#--------------------------------------------------------------------
---------
AdoRs. CursorLocation = 3 'const adUseClient = 3
AdoRs. Open SQLCmd, adoConn, 0, 2
'#--------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.