DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: displaying a databse on a webpage

  1. #1
    computer-nut Guest

    displaying a databse on a webpage


    I am quite new to ASP. I have (I think) a very simple question. In my DB folder
    I have created a database called test.mdb. In this database I have 1 table
    called "imran" and 5 fields called "first, last, email, nationality etc ".

    all the fields contain values.

    I am trying to get a listing of these values on a webpage, just as a very
    simple start. I use the code below


    <html>
    <head>
    <title> please work</title>
    </head>

    <body bgcolor="pink">

    <%
    Set Conn = Server.CreateObject("ADODB.Connection")
    sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("\immy52\db\test.mdb") & ";"
    & _
    "Persist Security Info=False"
    Conn.Open(sConnection)

    select * from imran;
    %>

    </body>
    </html>

    i recieve the following error message

    Microsoft VBScript compilation error '800a03fd'

    Expected 'Case'

    /immy52/index2.asp, line 15

    select * from imran;
    -------^



    can any body advise me as to where im going wrong

    thanks



  2. #2
    John Wood Guest

    Re: displaying a databse on a webpage

    I believe the syntax is SELECT <table name> WHERE <criteria>. You don't need to
    specify the field names since the records returned include all the fields. Has
    something to do with the the flavor of sql that sql server uses (ANSI vs
    whatever).
    John

    computer-nut wrote:

    > I am quite new to ASP. I have (I think) a very simple question. In my DB folder
    > I have created a database called test.mdb. In this database I have 1 table
    > called "imran" and 5 fields called "first, last, email, nationality etc ".
    >
    > all the fields contain values.
    >
    > I am trying to get a listing of these values on a webpage, just as a very
    > simple start. I use the code below
    >
    > <html>
    > <head>
    > <title> please work</title>
    > </head>
    >
    > <body bgcolor="pink">
    >
    > <%
    > Set Conn = Server.CreateObject("ADODB.Connection")
    > sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=" & Server.MapPath("\immy52\db\test.mdb") & ";"
    > & _
    > "Persist Security Info=False"
    > Conn.Open(sConnection)
    >
    > select * from imran;
    > %>
    >
    > </body>
    > </html>
    >
    > i recieve the following error message
    >
    > Microsoft VBScript compilation error '800a03fd'
    >
    > Expected 'Case'
    >
    > /immy52/index2.asp, line 15
    >
    > select * from imran;
    > -------^
    >
    > can any body advise me as to where im going wrong
    >
    > thanks



  3. #3
    John Wood Guest

    Re: displaying a databse on a webpage

    Disregard my post. That only applies to Delete queries. Guess I shouldn't be
    posting at 4AM. Sorry.
    John

    computer-nut wrote:

    > I am quite new to ASP. I have (I think) a very simple question. In my DB folder
    > I have created a database called test.mdb. In this database I have 1 table
    > called "imran" and 5 fields called "first, last, email, nationality etc ".
    >
    > all the fields contain values.
    >
    > I am trying to get a listing of these values on a webpage, just as a very
    > simple start. I use the code below
    >
    > <html>
    > <head>
    > <title> please work</title>
    > </head>
    >
    > <body bgcolor="pink">
    >
    > <%
    > Set Conn = Server.CreateObject("ADODB.Connection")
    > sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=" & Server.MapPath("\immy52\db\test.mdb") & ";"
    > & _
    > "Persist Security Info=False"
    > Conn.Open(sConnection)
    >
    > select * from imran;
    > %>
    >
    > </body>
    > </html>
    >
    > i recieve the following error message
    >
    > Microsoft VBScript compilation error '800a03fd'
    >
    > Expected 'Case'
    >
    > /immy52/index2.asp, line 15
    >
    > select * from imran;
    > -------^
    >
    > can any body advise me as to where im going wrong
    >
    > thanks



  4. #4
    Jaydes Guest

    Re: displaying a databse on a webpage


    You're getting an error because VB doesn't know what to do with the SQL statement
    "select * from...". Instead, you need to pass the SQL select statement to
    the data source thru ADO. There are many ways to do this, but here's one.

    When getting data from Access (or any database with ADO), you need to:

    - set up the connection string
    - open the connection
    - open the result recordset
    - navigate the recordset
    - close connection


    Try something like the following:
    (note: I didn't test it, so it may need some tweaking)
    --------------------------------
    Dim conn
    Dim rs

    set conn = Server.CreateObject("ADODB.CONNECTION")
    set rs = Server.CreateObject("ADODB.RECORDSET")

    '-set up the connection string
    sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("\immy52\db\test.mdb") & ";"
    & _
    "Persist Security Info=False"
    '-open the connection
    Conn.Open(sConnection)

    '-open the result recordset
    rs.open "select * from imran;", conn, adOpenForwardOnly, adLockReadOnly,
    adCmdText

    '-navigate the recordset
    If Not rs.BOF and Not rs.EOF Then
    Do Until rs.EOF
    Resonse.write( (rs.Fields("first") & "," & rs.Fields("last") & "," & rs.Fields("email"))
    )
    rs.MoveNext
    Loop
    End If

    '-clean up your room
    rs.close
    conn.close
    set rs = nothing
    set conn = nothing

    A good short summary about all this is available at:

    http://www.access-developer.com/articles.asp

    -Jay

    ---------------------------------------------------------------
    "computer-nut" <eazy@geek.com> wrote:
    >
    >I am quite new to ASP. I have (I think) a very simple question. In my DB

    folder
    >I have created a database called test.mdb. In this database I have 1 table
    >called "imran" and 5 fields called "first, last, email, nationality etc

    ".
    >
    >all the fields contain values.
    >
    >I am trying to get a listing of these values on a webpage, just as a very
    >simple start. I use the code below
    >
    >
    ><html>
    ><head>
    ><title> please work</title>
    ></head>
    >
    ><body bgcolor="pink">
    >
    ><%
    >Set Conn = Server.CreateObject("ADODB.Connection")
    >sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    > "Data Source=" & Server.MapPath("\immy52\db\test.mdb") & ";"

    & _
    > "Persist Security Info=False"
    >Conn.Open(sConnection)
    >
    >select * from imran;
    >%>
    >
    ></body>
    ></html>
    >
    >i recieve the following error message
    >
    >Microsoft VBScript compilation error '800a03fd'
    >
    >Expected 'Case'
    >
    >/immy52/index2.asp, line 15
    >
    >select * from imran;
    >-------^
    >
    >
    >
    >can any body advise me as to where im going wrong
    >
    >thanks
    >
    >


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center