open and read an access mdb

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default open and read an access mdb

    this is a little long but pretty basic, just trying to open the table
    'volunteerPrimary'
    and read back all the fields in it

    the code i'm trying to execute at the server is:
    <script language="vbscript" runat="server">
    <!-- open access data base with ado -->
    const adOpenDynamic =2
    const adLockOptimistic =3
    const adCmdTable =2
    private rs
    private firstname, lastname
    dim strDbConnection
    Dim fld
    dim recSource
    recSource = "SELECT * FROM volunteerPrimary"
    strDbConnection = "provider=microsoft.jet.oledb.4.0;" & _
    "data source=e:\inetpub\wwwroot\webasp\volunteer.mdb;"
    set rs = server.createobject("adodb.recordset")
    rs.open recSource, strDbConnect, adOpenDynamic, adLockOptimistic, adCmdTable
    For Each fld In rs.Fields
    response.write "next field found in table volunteerPrimary is " &
    fld.value & "<br>"
    Next
    rs.close
    set rs = nothing
    </script>

    the error i'm getting is:
    ADODB.Recordset error '800a0bb9'

    Arguments are of the wrong type, are out of acceptable range, or are in
    conflict with one another.

    /phsVolunteerData.asp, line 58

    if i substitute 'volunteerPrimary' for 'recSource' in the rs.open, it seems
    to open ok, can anybody see what i'm doing wrong??

    and..... when i try to 'dim fld as adodb.field' i get an error on that,
    expecting end of statement. so in vb script are all variables set up like
    the 'variants' in vb??




    bbxrider Guest

  2. Similar Questions and Discussions

    1. to open a pdf: at first agree to the terms,than it's possible to read the pdf
      Hi everybody, in the moment i have the following problem: for customers i have created an acrobat pdf-file. so i wish that every user who will...
    2. Read-Only Access
      I am new to Cold Fusion, is it possible to access a database as read-only? Due to the size of some of my tables, it takes forever for a single...
    3. Read/Write Access Error
      When trying to export a document that has a vector image in it as an eps, I get the following error: Error: Could not save the document because...
    4. read/write access
      I'm using FH 10 on a Windows 2000 PC at work, and yesterday when I tried to print I got a dialogue that said the command couldn't be completed...
    5. Open Access form without Access behind it
      How can I start(open) an Access form without having the Access database window opening behind it? Thanks, Ray Maas
  3. #2

    Default Re: open and read an access mdb

    Less code = less potential for error
    90% of the time the Conn.execute(sql) will do all you need

    dim rs,sql,conn

    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=
    e:\inetpub\wwwroot\webasp\volunteer.mdb;"
    sql = "SELECT * FROM volunteerPrimary"
    set rs = Conn.execute(sql)
    do while not rs.EOF
    response.write blah blah
    loop
    rs.close

    "bbxrider" <bbxrider1@comcast.net> wrote in message
    news:OnvsjLZTDHA.1288@tk2msftngp13.phx.gbl...
    > this is a little long but pretty basic, just trying to open the table
    > 'volunteerPrimary'
    > and read back all the fields in it
    >
    > the code i'm trying to execute at the server is:
    > <script language="vbscript" runat="server">
    > <!-- open access data base with ado -->
    > const adOpenDynamic =2
    > const adLockOptimistic =3
    > const adCmdTable =2
    > private rs
    > private firstname, lastname
    > dim strDbConnection
    > Dim fld
    > dim recSource
    > recSource = "SELECT * FROM volunteerPrimary"
    > strDbConnection = "provider=microsoft.jet.oledb.4.0;" & _
    > "data source=e:\inetpub\wwwroot\webasp\volunteer.mdb;"
    > set rs = server.createobject("adodb.recordset")
    > rs.open recSource, strDbConnect, adOpenDynamic, adLockOptimistic,
    adCmdTable
    > For Each fld In rs.Fields
    > response.write "next field found in table volunteerPrimary is " &
    > fld.value & "<br>"
    > Next
    > rs.close
    > set rs = nothing
    > </script>
    >
    > the error i'm getting is:
    > ADODB.Recordset error '800a0bb9'
    >
    > Arguments are of the wrong type, are out of acceptable range, or are in
    > conflict with one another.
    >
    > /phsVolunteerData.asp, line 58
    >
    > if i substitute 'volunteerPrimary' for 'recSource' in the rs.open, it
    seems
    > to open ok, can anybody see what i'm doing wrong??
    >
    > and..... when i try to 'dim fld as adodb.field' i get an error on that,
    > expecting end of statement. so in vb script are all variables set up like
    > the 'variants' in vb??
    >
    >
    >
    >

    only me Guest

  4. #3

    Default Re: open and read an access mdb


    "bbxrider" <bbxrider1@comcast.net> wrote in message
    news:epK9$HcTDHA.2220@TK2MSFTNGP11.phx.gbl...
    > thanks a lot, that works, duh, can't believe such a dumb mistake, am
    trying
    > to figure out why to
    > leave out the asCmdTable.

    more to the point, why put it in?

    caused a error for me

    > "Mosley" <home@that.com> wrote in message
    > news:Ok5QBybTDHA.2280@TK2MSFTNGP12.phx.gbl...
    > >
    > > "bbxrider" <bbxrider1@comcast.net> wrote in message
    > > news:OnvsjLZTDHA.1288@tk2msftngp13.phx.gbl...
    > > > this is a little long but pretty basic, just trying to open the table
    > > > 'volunteerPrimary'
    > > > and read back all the fields in it
    > > >
    > >
    > >
    > > you are using "strDbConnect" to connect when you set varible as
    > > "strDbConnection"
    > >
    > > remove ", adCmdTable"
    > >
    > >
    > > your new code
    > >
    > >
    > > <script language="vbscript" runat="server">
    > > const adOpenDynamic =2
    > > const adLockOptimistic =3
    > > const adCmdTable =2
    > > private rs
    > > private firstname, lastname
    > > dim strDbConnection
    > > Dim fld
    > > dim recSource
    > > recSource = "SELECT * FROM lastDate"
    > > strDbConnection = "provider=microsoft.jet.oledb.4.0;" & _ "data
    > > source=c:\temp\stats.mdb;"
    > > set rs = server.createobject("adodb.recordset")
    > > rs.open recSource, strDbConnection,adOpenDynamic,adLockOptimistic
    > > For Each fld In rs.Fields
    > > response.write "next field found in table volunteerPrimary is " &
    > fld.value
    > > Next
    > > rs.close set rs = nothing
    > >
    > >
    > >
    > >
    > >
    > >
    > > > the code i'm trying to execute at the server is:
    > > > <script language="vbscript" runat="server">
    > > > <!-- open access data base with ado -->
    > > > const adOpenDynamic =2
    > > > const adLockOptimistic =3
    > > > const adCmdTable =2
    > > > private rs
    > > > private firstname, lastname
    > > > dim strDbConnection
    > > > Dim fld
    > > > dim recSource
    > > > recSource = "SELECT * FROM mytable"
    > > > strDbConnection = "provider=microsoft.jet.oledb.4.0;" & _
    > > > "data source=e:\inetpub\wwwroot\webasp\volunteer.mdb;"
    > > > set rs = server.createobject("adodb.recordset")
    > > > rs.open recSource, strDbConnect, adOpenDynamic, adLockOptimistic
    > >
    > >
    > >
    > >
    > >
    > > > For Each fld In rs.Fields
    > > > response.write "next field found in table volunteerPrimary is " &
    > > > fld.value & "<br>"
    > > > Next
    > > > rs.close
    > > > set rs = nothing
    > > > </script>
    > > >
    > > > the error i'm getting is:
    > > > ADODB.Recordset error '800a0bb9'
    > > >
    > > > Arguments are of the wrong type, are out of acceptable range, or are
    in
    > > > conflict with one another.
    > > >
    > > > /phsVolunteerData.asp, line 58
    > > >
    > > > if i substitute 'volunteerPrimary' for 'recSource' in the rs.open, it
    > > seems
    > > > to open ok, can anybody see what i'm doing wrong??
    > > >
    > > > and..... when i try to 'dim fld as adodb.field' i get an error on
    that,
    > > > expecting end of statement. so in vb script are all variables set up
    > like
    > > > the 'variants' in vb??
    > > >
    > > >
    > > >
    > > >
    > >
    > >
    >
    >


    Mosley Guest

Posting Permissions

  • You may not post new threads
  • You may 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