Forum Moderators: open

Message Too Old, No Replies

Database update problem

Access DB using ASP and VB

         

mahalie

5:11 pm on Oct 26, 2005 (gmt 0)

10+ Year Member



Let me preface by saying I'm very new to ASP/SQL Server and I'm on a corporate intranet with no reasonable documentation. I'm trying to expand the functionality of an existing script the collects and displays form data.

Here's some of the code I'm working with:


Dim adoRS
Set adoRS = Server.CreateObject("ADODB.Recordset")
adoRS.ActiveConnection = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Server.MapPath("db_events.mdb") & ";"
Server.CreateObject("ADODB.Connection")

If Request.QueryString("command")= "submit" Then

Dim SQL
SQL = "UPDATE " & HolidayParty2005 & " SET wf_inputName='"
SQL = SQL & Request.Form("wf_inputName") & "'"
SQL = SQL & " WHERE ID=" & Request.Form("ID")

adoRS.Open SQL,,2,2
adoRS.Close
Set adoRS = Nothing

ELSE other stuff that works fine

The error I've been getting is:
ADODB.Recordset error '800a0bb9'

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

As a side note, this exact method/syntax works for inputing new records, and displaying records. I've response.written my SQL statement, declared Option Explicit, etc. Searching through forums I haven't been able to find a similar case...most suggestions related to this error have to do with the cursor and lock type constants not being avail - but since I use the numbers that shouldn't be relevant, right?

Any help is REALLY appreciated! I'm at my wits end and would like to get this thing running (it's SO close) before I read another big book on ASP - it'll take me a while.

mahalie

11:02 pm on Oct 26, 2005 (gmt 0)

10+ Year Member



In the past few hours I've slowly chipped away at realizing there is a whole lot wrong with the above. But in short, for those having similar problems, here's what worked.

<%
Dim SQLselect
SQLselect = "SELECT wf_inputName FROM " & tableName
SQLselect = SQLselect & " WHERE ID=" & Request.Form("ID")

Dim SQL
SQL = "UPDATE " & tableName & " SET " & "wf_inputName='" & Request.Form("wf_inputName") & "'"
SQL = SQL & " WHERE ID=" & Request.Form("ID")

'setup connection
Dim oConn ' object for ADODB.Connection obj
Dim oRs ' object for output recordset object
Dim filePath ' Directory of events_db.mdb file

' Map authors database to physical path
filePath = Server.MapPath("database.mdb")

' Create ADO Connection Component to connect with database

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
' To add, delete and update recordset, it is recommended to use
' direct SQL statement instead of ADO methods.

oConn.Execute SQL
Set oRs = oConn.Execute ( SQLselect )
%>

I was having a horrifying time trying to use ADO methods to update the database. I already had a working example the inserted new info so I thought it should be pretty easy and similar. Doh! In the beginning I didn't realize the file I was editing was using ADO methods (NEWBIE!) so SQL couldn't be passed the way I did in the previous example.

Here are the articles that helped me:
[aspfaq.com...]
[aspfaq.com...]

Code example:
[microsoft.com...]