Page 306 - DCAP408_WEB_PROGRAMMING
P. 306

Web Programming




                    Notes          14.2 Reading Records from Database

                                   Databases  and ASP (Communicating with a Database  using ActiveX  Data Objects  (ADO);
                                   Connecting to a Database (The Connection Object,  Using a System DSN, Using a  DSN-less
                                   Connection, Opening  the Connection, Closing the connection, Properties of the connection);
                                   Reading data from a Database (The Recordset Object, Using adovbs.inc, Reading and Displaying
                                   the contents of a Database Table).
                                   Internet programming is one of the most exciting new fields to develop in recent years, and will
                                   continue growing in importance, especially for Visual Basic programmers. In response, Microsoft
                                   is pushing hard to integrate several of its key technologies, in order to allow developers to create
                                   Internet solutions that scale well and that are quick to develop. Server-side technologies are where
                                   the new advances in Internet technology will likely be made – at least in the near future, which is
                                   about as far as we can ever see in today’s rapidly changing technological landscape.
                                   Active Server Pages (ASP) is a server-side technology that accomplishes this very feat: an ASP
                                   script is a combination of HTML and ASP objects that work together to produce a pure HTML
                                   file. The client never sees the script, which resides on the server, they just see the output. ASP is
                                   basically a collection of objects that handle all aspects of a Web site, from communicating with
                                   the  client,  to  managing  multiple  connections.  ASP  is  firmly  grounded  in  Visual  Basic
                                   programming concepts. In fact, Visual  Basic is rapidly emerging as a  premier language  for
                                   developing Web solutions, as you will appreciate by the end of this article. My concern here is
                                   a DSN-less connection.
                                   A DSN-less connection is operationally identical to a DSN except that the server doesn’t have to
                                   access the registry to access the parameters since they’re all specified in the connection string itself.



                                     Did u know?  Which parameter is required by ODBC connection?

                                     The only parameter required by all ODBC connection strings is Driver which specifies
                                     which driver to use. Unfortunately this isn’t enough to get connected to anything and
                                     additional information is required by each driver.
                                   Now we will see how we read a database using ASP(communicating with a database Active X
                                   Data Objects(ADO),connecting to a database using a DSN-less connection, its opening ,closing,
                                   properties &of course reading the data, displaying it using adovbs.inc.

                                   14.2.1 Reading Records with ADO


                                   Recordset Object

                                   The recordset object provides a relatively simple interface o read records from a database.
                                   ADO was introduced  and thrived in  a  time-frame  when connected  and (mostly)  two-tier
                                   applications were moving to a more layered and Web-based architecture. The overall ADO
                                   object model design reflects this transition.
                                   The Web forced the adoption of a disconnected model where more and more information is
                                   downloaded and cached on the client. Within ADO, you find two souls hidden just under the
                                   skin of the Recordset object.

                                   The Recordset can leverage server cursors and do what it is supposed to do being connected to
                                   the data source all the time. At  the same  time,  another  facet of the same object can  work
                                   disconnected and build up a correct representation of records in two ways. Either it can fetch




          300                               LOVELY PROFESSIONAL UNIVERSITY
   301   302   303   304   305   306   307   308   309   310   311