• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 15. Using ASP with JavaScript > Reading and Displaying Multiple Fields

Reading and Displaying Multiple Fields

The first script showed only one field, to simplify the process and focus on what needed to be done for connection. The following script looks at all nine fields and all the records in the fields. Save the script in your root directory or subdirectory in the root directory.

ReadDB2.asp

<% 
Dim hookUp, Conn, ViewRecord, ID, Lname, Fname, Address, City, State, Zip, Phone, Email, 
display, SQL 
hookUp= "Driver={Microsoft Access Driver (*.mdb)}; 
DBQ=d:\Inetpub\Wwwroot\hotJava\javaS.mdb;" 
Set Conn = Server.CreateObject("ADODB.Connection") 
Set ViewRecord = Server.CreateObject("ADODB.Recordset") 

Conn.Open hookUp 
SQL="SELECT * FROM JavaStable" 
ViewRecord.Open SQL, Conn 
Do While Not ViewRecord.EOF 
      ID=ViewRecord("ID") 
      Lname=ViewRecord("Lname") 
      Fname=ViewRecord("Fname") 
      Address=ViewRecord("Address") 
      City=ViewRecord("City") 
      State=ViewRecord("State") 
      Zip=ViewRecord("Zip") 
      Phone=ViewRecord("Phone") 
      Email=ViewRecord("Email") 
      display =display & ID & "<br>" & Fname & Space(1) & Lname & "<br>" & Address & "<br>" 
      & City & "," & Space(1) & State & Space(1) & Zip &  "<br>" & Phone & "<br>" & Email 
      & "<p>" 
      ViewRecord.MoveNext 
Loop 
 Response.Write display 

ViewRecord.Close 
Conn.Close 
Set ViewRecord = Nothing 
Set Conn = Nothing 
%> 

					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint