Groups > Databases > Access Databases and AccessDataSource Control > Re: display records from access database in asp page




Re: display records from access database in asp page

Re: display records from access database in asp page
Wed, 26 Mar 2008 20:19:39 +000
thanks for your feedback, mike. the problem is that i am using FrontPage 2003
(yes...i know). do you have any other suggestions based on that?
Post Reply
Re: display records from access database in asp page
Wed, 26 Mar 2008 20:33:12 +000
rquitania:

the problem is that i am using FrontPage 2003 (yes...i know). do you have any
other suggestions based on that?
 

 

The fact that you recognise it as a problem is a good sign ;-)  Click the
Downloads link and get hold of Visual Web Developer.  It's completely free.  Get
Sql Server Express as well.  That's free too. If you want to stick with Access,
here's a fantastic set of tutorials:
http://msconline.maconstate.edu/tutorials/aspnet20/default.htm
Post Reply
display records from access database in asp page
Wed, 26 Mar 2008 22:14:20 +000
the records in my access database are not being displayed on my asp page. i've
look on many websites and it appears that i am on the right track. however, my
asp page is BLANK!

here is my code:

        <%
        '----------------------------------------------------------------------
        ' All your ASP preprocessing code goes here
        '----------------------------------------------------------------------
        ' -- Declare Variables
        Dim objConn                        ' Our Connection Object
        Dim objRS                        ' Our Recordset Object
        Dim strSQL                        ' Our SQL String to access the
database
        Dim strConnection                 ' Our Connection string to access the
database
        Dim i                            ' a counter variable
        
        ' -- Create objects
        Set objConn = Server.CreateObject("ADODB.Connection")
        Set objRS = Server.CreateObject("ADODB.Recordset")
        
        ' -- Open the Connection
        objConn.Provider="Microsoft.Jet.OLEDB.4.0"
        objConn.Open "C:\Inetpub\wwwroot\message.mdb"
        
        ' -- Our SQL Statement
        strSQL = "SELECT fullName,email,comment FROM tblMessage"
        
        ' -- Populate our Recordset with data
        set objRS = objConn.Execute (strSQL)
        
        
        if (objRS.BOF and objRS.EOF) then
            response.write "No records found"
            response.end
        End if
        '----------------------------------------------------------------------
        ' Begin HTML output
        '----------------------------------------------------------------------
        %>
        <TABLE BORDER="1" CELLPADDING="2"
CELLSPACING="1" WIDTH="100%">
        <%
            ' -- Output the Field Names as the first row in the table
            Response.Write "<TR
BGCOLOR=""#CCCCCC"">"
            For i = 0 to objRS.Fields.Count - 1
                Response.Write "<TH><FONT
FACE=""ARIAL"" SIZE=""2"">"
& objRS.Fields(i).Name & "</FONT></TH>"
            Next
            Response.write "</TR>"
            
            ' -- Now output the contents of the Recordset
            objRS.MoveFirst
            Do While Not objRS.EOF
                ' -- output the contents
                Response.Write "<TR>"
                For i = 0 to objRS.Fields.Count - 1
                    Response.Write "<TD><FONT
FACE=""ARIAL"" SIZE=""1"">"
& objRS.Fields(i) & "</FONT></TD>"
                Next
                Response.write "</TR>"
                ' -- move to the next record
                objRS.MoveNext
            Loop
        
            objRS.Close
            set objRS = Nothing
            objConn.Close
            set objConn = Nothing        
            
         %>
        </TABLE>
        
        <%
        '----------------------------------------------------------------------
        ' End HTML Output
        '----------------------------------------------------------------------
        
        '----------------------------------------------------------------------
        ' All ASP post processing code goes here, as well as 
        ' sub routines and functions
        '---------------------------------------------------------------------- 
      
        
         %>
Post Reply
Re: display records from access database in asp page
Wed, 26 Mar 2008 23:14:22 +000
If you are just learning web development, and you have a choice, I would ditch
ASP if I were you, and learn ASP.NET instead.  The "Classic" ASP that
you are using has not been developed since around Y2K, when Microsoft released
the .Net Framework.  If you can learn ASP.NET instead, you will find loads of
help (videos, tutorials, free software) at the Learn link at the top of the
page.  You could end up putting a load of effort into Classic ASP, then find
that no one is employing people with those skills anymore.

Try changing "if (objRS.BOF and objRS.EOF) then" to "if
(objRS.BOF or objRS.EOF) then"
Post Reply
about | contact