Join TSR now and get all your revision questions answeredSign up now
    • 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
 
 
 
Poll
Which pet is the best?

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

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