SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Updating MS Access database, onclick of a button in a ASP page

    hi,

    I am trying to update the MS Access database from a ASP page. On click of a button I want some value(say '1') to be written to the database. For that I am writing following code. But the code is not working.

    rsWrite.Open "SELECT * from [input]", connWrite,_
    adOpenDynamic, adLockBatchOptimistic

    for the above line, it gives me an error that
    ADODB.Recordset (0x800A0BB9)
    Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

    If anyone has any suggestions, please let me know.

    <%
    Sub butEstopClick
    Dim connStringWrite
    'Set connWrite = New ADODB.Connection
    Set connWrite = Server.CreateObject("ADODB.Connection")
    connStringWrite = "DRIVER={Microsoft Access Driver .mdb)};" &_
    "DBQ=C:\Inetpub\wwwroot\RAL\test.mdb;DefaultDir=;UID=;PWD=;" &_
    "Mode = readwrite"
    connWrite.Open connStringWrite

    Set rsWrite = Server.CreateObject("ADODB.RecordSet")
    strSQL = "SELECT * from [input]"

    rsWrite.Open "SELECT * from [input]", connWrite,_
    adOpenDynamic, adLockBatchOptimistic

    'Do While not rsWrite.EOF
    rsWrite.Fields("Estop").Value = 1
    rsWrite.Update
    rsWrite.Fields("Reset").Value = 0
    rsWrite.Update

    rsWrite.Close
    connWrite.Close
    %>

    End Sub
    <INPUT type="button" value="ESTOP" id=butEstop name=butEstop onclick="<%butEstopClick%>">

  2. #2
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is "Input your field name or is it a value you want to change dynamicaly depending on what value was updated?

    If so change the code from [Input] to '"& Input &"'

    Hope that helps
    .NET Code Monkey

  3. #3
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    input is my MS access table name, from which the page accesses the data.

  4. #4
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change

    Code:
    rsWrite.Open "SELECT * from [input]", connWrite,_ 
    adOpenDynamic, adLockBatchOptimistic
    to

    Code:
    rsWrite.Open strSQL, connWrite,_ 
    adOpenDynamic, adLockBatchOptimistic
    .NET Code Monkey

  5. #5
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You already had your SQL statment in strSQL

    Can't belive I missed it before.

    Secondly, if you are updating you will need a WHERE clause in your SQL statment.

    hope this helps
    Last edited by big_al; Dec 4, 2001 at 23:43.
    .NET Code Monkey

  6. #6
    SitePoint Member
    Join Date
    Oct 2001
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It gives me the same error, even after changing the code

    strSQL = "SELECT [Estop], [Reset] from [input]"
    'Estop and Reset are field names in the input table.

    rsWrite.Open strSQL, connWrite,_
    adOpenDynamic, adLockBatchOptimistic

    'above line
    'gives this error
    'ADODB.Recordset (0x800A0BB9)
    'Arguments are of the wrong type, are out
    'of acceptable range, or are in conflict with one
    'another.


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
  •