Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error using form value in Access Update

Status
Not open for further replies.

werosen1

Programmer
Mar 30, 2006
16
US
I'm having a problem updating my Access 2002 db using an ASP variable whose value is provided from a form text box.

If I simply use the following, the db is updated correctly with the number 5.

Set conn = server.createobject("adodb.connection")
conn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\tradersreportsdata\reportevents.mdb"

conn.Open
Set rs=Server.CreateObject("ADODB.recordset")

rs.open "UPDATE reports SET ActVal = '5' WHERE rID = 38;", conn

conn.close
Set conn = Nothing

However, if I use this:

Set conn = server.createobject("adodb.connection")
conn.connectionstring = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=C:\tradersreportsdata\reportevents.mdb"

conn.Open
Set rs=Server.CreateObject("ADODB.recordset")

rs.open "UPDATE reports SET ActVal = 'ActVal38' WHERE rID = 38;", conn

conn.close
Set conn = Nothing

where ActVal38 is the variable name I want to update the database with, it just puts the characters ActVal38 into the db.

Can someone tell me what I'm doing wrong?

Regards
 
Your update statement is acutally attempting to put the string "ACTVAL38" into what is probably a number field.

I was just passing through this forum and am not an expert on ASP, I write primarily in VB. My thought for you is that you need to construct your SQL statment using a concantentation with the value stored in the Form field.
Something like
rs.open "Update reports Set ActVal = '" & ACTVAL38 & "' WHERE rID = 38;", conn





Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Wow. I've been breaking my back on this for hours and couldn't find any resource that mentions this.

It works perfectly.

Thanks much.
 
Your welcome.

Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top