Webcomputing━ado Summary Report 1

Source: Internet
Author: User
Tags object model odbc connection
Ado|web in today's various Dynamic Web page (Dhtml) solutions have emphasized the connection with the database, in fact, web-linked background database is currently a popular application, E-commerce and other fields have a wide range of applications. Microsoft has introduced a new ADO (Active Data Object) model to accommodate its development, with an ODBC connection to provide a convenient, fast-clean connection to the current popular desktop database system. Here, I want to summarize the ADO objects and their respective properties and methods through the application of ADO in ASP technology.
One, ADO object model:
The following is a brief introduction to the object Model of ADO
ADO has three main objects, the Connection object, the Command object, and the Recordset object.
Connection (object)
─errors (set) ─error (object)
Command (object)
─parameters (set) ─parameter (object)
RecordSet (object)
─fields (set) ─field (object)
Where the Connection object, the Command object, The Recordset object and the Field object also produce the Properity object, each with a properities collection. We have a good understanding of these objects in ASP programming. The following are the relationships between the three main objects.
Command.activeconnection->connection
Recordset.activeconnection->connection
Connection.execute->recordset
Command.execute->recordset
Recordset.source->command
Well, with the above relational table, you should be able to understand some of the equivalent forms of expression.
Form 1
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
strconn = "Driver={sql server};server=srv;" & _
"Uid=sa;pwd=;d atabase=pubs"
strSQL = "SELECT * from Employee;"
Rs.Open Strsql,strconn,,, adCmdText
Form 2
Set conn = Server.CreateObject ("ADODB. Connection ")
strconn = "Driver={sql server};server=srv;" & _
"Uid=sa;pwd=;d atabase=pubs"
Conn.Open strconn
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
Rs. Activeconnection=conn (note this sentence)
strSQL = "SELECT * from Employee;"
Rs.Open strSQL,,,, adCmdText
"The above sentence can also be written as Rs.Open strsql,conn,,, adCmdText
Form 3
Set conn = Server.crreateobject ("ADODB. Connection ")
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
strconn = "Driver={sql server};server=srv;" & _
"Uid=sa;pwd=;d atabase=pubs"
Conn.Open strconn
strSQL = "SELECT * from Employee;"
Rs=conn. Execute strSQL (Note the second sentence)
Form 4
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
strconn = "Driver={sql server};server=srv;" & _
"Uid=sa;pwd=;d atabase=pubs"
strSQL = "SELECT * from Employee;"
Rs.Open Strsql,strconn,,, adCmdText

Note: The example above assumes the name=srv of SQL Server, using SQL Server Authentication to use the default account SA, which does not have a password set.

Each of these forms can produce an instance RS of the same Recordset object, but the methods are different, and in the later discussion we will see their differing advantages.



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.