Query MS Access Database with OleDB in ASP.net

                                                        
1
2
3 <%@ import namespace="system.data.oleDb" %>
4
5 <Script runat="server">
6
7 Sub page_load
8
9 Dim dbconn as oledbConnection
10 Dim dbCMD as oleDbCommand
11 Dim dtr as oledbdatareader
12
13 ' Server.MapPath("[relative path to your database]")
14 dbConn = New oledbConnection ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & server.MapPath("/test.mdb"))
15 dbConn.open()
16 dbCMD = new oleDbCommand ("select * from tblContact",dbconn)
17 dtr = dbCMD.executereader()
18
19 While dtr.read()
20 response.write ("
  • ")
    21 response.write (dtr(0) & "---" & dtr(1))
    22 End while
    23
    24 dtr.close()
    25 dbConn.close()
    26
    27 End Sub
    28
    29 Script>
    30
    31
    32

    • 0 Users Found This Useful
    Was this answer helpful?

    Related Articles

    Sample Code on Sending Email using ASP.NET 1

    Our mail server is configured with SMTP authentication and all your code need to use SMTP...

    Sample Code on how to send email using ASP.NET 2

    For ASP.NET 2 you no longer using System.Web.Mail, but you will be using System.Net.Mail and the...

    Query MySQL Database in ASP.net

    1 2 3 <%@ Page Language="VB"...