Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Aug 2005
    Location
    London/Kingston, Surrey, United Kingdom
    Posts
    518
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Connect Access with ASP

    Does anyone know how to connect Microsoft Access 2003 with ASP and what do i need?

    Cheers

    Skender

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Connect Access with ASP

    Creating a web application that can interact with a database is no easy task. The quickest approach would be to use the Data Access Pages that are integrated into the MS Access environment.

    If that's not quite what you need, you'll have to step into the world of custom coding. You may want to Google for Access and ASP.

    (By the way - do you mean ASP or ASP.NET?)

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Connect Access with ASP

    If you are using ASP "Classic" rather than ASP.Net (.aspx), then your ASP pages probably will use ADO (ActiveX Data Objects) to read from and write to your database. Some ADO stuff on this board and lots on the Access board and tons out on the web, although it's hard to search for ADO and not get lots of ADO.Net.

  4. #4
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Warrington, Cheshire
    Posts
    355
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Connect Access with ASP

    Just copied this from brief page.
    Hope it helps or at least sends you in right direction.(spurious Dims not bothered deleting)

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Thread.CurrentThread.ApartmentState = ApartmentState.STA

    bindtestSummary()
    End Sub
    Sub bindtestSummary()
    Dim objConn5 As New OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0; Data Source=C:inetpubwwwrootMy_tables.mdb")
    Dim objCmd As OleDbCommand
    Dim objRdr As OleDbDataReader
    Dim strCmd As String
    Dim MyDataset As New DataSet
    Dim dsMyDataset As DataSet
    Dim strYTDMarg As String
    objConn5.Open()

    Dim oleAdapt As New OleDbDataAdapter("SELECT " & _
    "reporttoname, sum(finalsales) AS YTDSales, " & _
    "sum(finalsales) as MTDSales FROM tbl_GMRData WHERE AccLedgerMonth=3 GROUP BY reporttoname ", objConn5)

    objConn5.Close()
    oleAdapt.Fill(MyDataset)
    TestSummary.DataSource = MyDataset

    TestSummary.DataBind()

    End Sub

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Connect Access with ASP

    As a note to anyone reading, that example uses ADO.Net objects and a syntax that the ASP (classic) DLL won't process. Here is an example of the older ASP syntax (using VBScript) connecting and saving a new record to an MDB:

    <code>' Do the Access database update
    Dim objConnA, strConnectA, objRSA
    ' Set up connection object and OLEDB string for local Access database
    Set objConnA = Server.CreateObject("ADODB.Connection")
    strConnectA = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("directory1/filename.mdb") & ";" & _
    "Jet OLEDB:System Database=" & Server.MapPath("directory2/filename.mdw") & ";" & _
    "User ID=username;Password="
    ' Open the connection
    objConnA.Open strConnectA
    ' Set up recordset and run query
    Set objRSA = Server.CreateObject("ADODB.Recordset")
    objRSA.Open "MyTable", objConnA, adOpenKeySet, adLockOptimistic, adCmdTable

    If objRSA.EOF Then
    objConnA.Close
    Response.Write "Unexpected EOF!" & vbCrLf & "Please contact Jefferson."
    Else
    ' Add new record to the recordset
    objRSA.AddNew
    ' Populate fields with form data and other stuff
    objRSA("MyField1") = Request("MyData1")
    ' et cetera...
    If Trim(Request.ServerVariables("REMOTE_HOST")) <> "" Then
    objRSA("UserIP") = Request.ServerVariables("REMOTE_HOST")
    Else
    objRSA("UserIP") = Request.ServerVariables("REMOTE_ADDR")
    End If
    ' Save new record, close down database objects
    objRSA.Update
    objRSA.Close
    objConnA.Close
    End If
    ' Clean Up
    Set objRSA = Nothing
    Set objCommandA = Nothing
    Set objConnA = Nothing</code>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •