Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    I am trying to use a MS Access database in a piece of code.
    I am using the exact same code that our lecturer used, however I am getting an error.

    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.Data.ODBC" %>
    <script runat="server">
    Sub Page_Load()
    Dim cs As String = "Driver={Microsoft Access Driver (*.mdb, *.accdb)};" + _
    "Dbq=" + Server.MapPath("People.accdb") + ";"
    Dim cn As New OdbcConnection(cs)
    Dim cmd As OdbcCommand
    Dim r As OdbcDataReader
    Dim s As String
    cmd = New OdbcCommand("SELECT * FROM People;", cn)
    cn.Open()
    r = cmd.ExecuteReader()
    s = ""
    Do While r.Read()
    s = s & r("Surname") & "<br />"
    Loop
    cn.Close
    parData.InnerHtml = s
    End Sub
    </script>


    The lines in bold were giving me problems but are now fixed due to an error in the Table name.
    However, now the Surnames are not displaying on the page I want as the page is just blank when I run the code.

    Any help as I am a programming novice.

    Thanks
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: March 28, 2013

University open days

  1. University of Bradford
    University-wide Postgraduate
    Wed, 25 Jul '18
  2. University of Buckingham
    Psychology Taster Tutorial Undergraduate
    Wed, 25 Jul '18
  3. Bournemouth University
    Clearing Campus Visit Undergraduate
    Wed, 1 Aug '18
Poll
How are you feeling in the run-up to Results Day 2018?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.