Professional Web Applications Themes

Access Query in ASP - ASP Database

I would like to use Accesss queries in ASP. This queries are done before in Access. I Know that i can access these queries using Visual Basic as below '**************************** Sub RunAccMacro() Dim oAccess as Object, oDB as Object Set oAccess = CreateObject("Access.Application") oAccess.Visible = True oAccess.OpenCurrentDatabase "C:\DB1.mdb" oAccess.Run "MyAccessMacro" End Sub '*************************** I got this code from msdn.com is it possible to do same thing by ASP. if possiblle i need sample. Thank you....

  1. #1

    Default Access Query in ASP

    I would like to use Accesss queries in ASP. This queries are done
    before in Access. I Know that i can access these queries using Visual
    Basic as below

    '****************************
    Sub RunAccMacro()
    Dim oAccess as Object, oDB as Object
    Set oAccess = CreateObject("Access.Application")
    oAccess.Visible = True
    oAccess.OpenCurrentDatabase "C:\DB1.mdb"
    oAccess.Run "MyAccessMacro"
    End Sub
    '***************************


    I got this code from msdn.com
    is it possible to do same thing by ASP. if possiblle i need sample.

    Thank you.
    Ambassador Guest

  2. #2

    Default Re: Access Query in ASP

    Ambassador wrote:
    > I would like to use Accesss queries in ASP. This queries are done
    > before in Access. I Know that i can access these queries using Visual
    > Basic as below
    >
    > '****************************
    > Sub RunAccMacro()
    > Dim oAccess as Object, oDB as Object
    > Set oAccess = CreateObject("Access.Application")
    > oAccess.Visible = True
    > oAccess.OpenCurrentDatabase "C:\DB1.mdb"
    > oAccess.Run "MyAccessMacro"
    > End Sub
    > '***************************

    This is code to run a macro. Are you asking how to run a macro or a saved
    query?


    Here's an example for running a saved query. There are other ways, but I
    like this the best:

    For a saved action query (no records returned) called qryHotels:
    'Open a connection
    set cn=server.createobject("adodb.connection")
    cn.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=DB1.mdb"
    cn.qryHotels
    cn.close: set cn=nothing

    'For a saved query that returns records:

    'Open a connection
    set cn=server.createobject("adodb.connection")
    cn.open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=DB1.mdb"
    set rs=server.createobject("adodb.recordset")
    cn.qryHotels rs
    if rs.eof then
    response.write "No records were returned"
    else
    'write the results to a table:
    Response.Write "<table border=1><tr><td>"
    sHTML=rs.GetString(2,,"</td><td>", _
    "</td></tr><tr><td>","NA")
    sHTML = Left(sHTML, len(sHTML) - 8)
    response.Write sHTML
    response.write "</table>"
    end if
    rs.close: set rs=nothing
    cn.close: set cn=nothing

    If your saved query takes parameters:

    cn.qryHotels parmval1, ..., parmvalN

    or

    set rs=server.createobject("adodb.recordset")
    cn.qryHotels parmval1, ..., parmvalN, rs


    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  3. #3

    Default Re: Access Query in ASP

    You can access a query (assuming no parameters) just like a table in
    ASP.

    And this works for a SQL statement:
    strSQL = "SELECT * FROM MyQuery"

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

Similar Threads

  1. Access Query
    By dave in forum Coldfusion Database Access
    Replies: 5
    Last Post: February 21st, 08:20 PM
  2. MS Access query in MX 7
    By Eric Hung in forum Coldfusion Database Access
    Replies: 2
    Last Post: March 19th, 03:31 AM
  3. Access query help
    By Brandon Taylor in forum Dreamweaver AppDev
    Replies: 1
    Last Post: March 12th, 09:52 PM
  4. Getting 0 recordset in MS Access Query
    By jt in forum ASP Database
    Replies: 4
    Last Post: May 24th, 04:27 AM
  5. MS access SQL query help!
    By Ralph Sharett in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 28th, 12:54 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139