Documente Academic
Documente Profesional
Documente Cultură
2012
In this paper we will talk about ADO and will give some samples to use this technology in web ,then first of all what is ADO ? Microsoft's ActiveX Data Objects (ADO) is a set of Component Object Model (COM) objects for accessing data sources . ADO allows a developer to write programs that access data without knowing how the database is implemented. He must be aware of the database for connection only. No knowledge of SQL is required to access a database when using ADO, although one can use ADO to directly execute SQL commands. The disadvantage of the latter is that it introduces a dependency upon the type of database used. ADO is positioned as a successor to Microsoft's earlier object layers for accessing data sources, including RDO (Remote Data Objects) and DAO (Data Access Objects). ADO was introduced by Microsoft in October 1996. Basic steps are required in order to be able to access data using ADO :
Create a connection object to connect to the database. Create a recordset object in order to receive data in. Open the connection Populate the recordset by opening it and passing the desired table name or SQL statement as a parameter to open function. Do all the desired searching/processing on the fetched data. Commit the changes you made to the data (if any) by using Update or UpdateBatch methods. Close the recordset Close the connection In below we will give samples for above steps for use in web platform :
AzerNet IT solution Center |ADO technology in Web 1
<% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs=Server.CreateObject("ADODB.recordset") rs.Open "Customers", conn %>
<html> <body> <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" set rs = Server.CreateObject("ADODB.recordset") sql="SELECT Companyname, Contactname FROM Customers ORDER BY CompanyName" rs.Open sql, conn %> <table border="1" width="100%"> <tr> <%for each x in rs.Fields response.write("<th>" & x.name & "</th>") next%> </tr> <%do until rs.EOF%> <tr> <%for each x in rs.Fields%> <td><%Response.Write(x.value)%></td> <%next rs.MoveNext%> </tr> <%loop rs.close conn.close%> </table> </body> </html>