Hey there! Sign in to join this conversationNew here? Join for free
    • 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
 
 
 
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Has a teacher ever helped you cheat?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • 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.