|
 |
access_asp thread: UPDATE variables strings vs numbers
Message #1 by "Mack Samuel" <mack.samuel@h...> on Wed, 27 Mar 2002 14:43:54
|
|
Help! Can anyone explain to me -- or point me to a web site -- how to
handle ASP variables in SQL statements (especially UPDATE statements)?
It seems that I can get some UPDATE statements to work fine, especially
when I pass variables into the SQL that are based on string values.
However, as soon as I use a variable that contains a number, see below, I
get in trouble.
What's the correct syntax for referring to ASP variables in an SQL
statement?
Does this work (in theory)?
objConn.execute("UPDATE Events SET AvailableSpaces = '"&
strAvailableSpaces &"' WHERE EventID = " & npID)
Any ideas or suggestions anyone?
Thanks much.
PS: Do I really need to worry about cursors and locks and all that?
=========================================================
Error message:
=========================================================
Data type mismatch in criteria expression.
/events/updateEvent.asp, line 13
=========================================================
Troublesome code:
=========================================================
<% @Language = VBScript%>
<% Option Explicit %>
<!--#include file="connect.asp"-->
<%
Dim RS, strAvailableSpaces, npID
' AvailableSpaces and eventID were not passed through a form,
npID = trim(request("eventID"))
strAvailableSpaces = trim(request("AvailableSpaces"))
objConn.open
' line 13 below:
Set RS = objConn.execute("UPDATE Events SET AvailableSpaces = '"&
strAvailableSpaces &"' WHERE EventID = " & npID)
Message #2 by "Mack Samuel" <mack.samuel@h...> on Wed, 27 Mar 2002 19:52:18
|
|
All right. I've figured it out on my own.
One of the variables had to be converted to the correct data type, of
course, so that my MS Access db would allow me to update the records,
according to the values my variables contained.
If anyone knows more than what little I know about VB variables in ASP,
please point me to a good resource site. I'm especially interested in
finding out as much as possible about proper variable syntax (whatever
type they are, string, int, etc.).
In case this might help somebody else, here's how I fixed my own problem:
Dim eName, npAS, npSQL, npID
' Values were not passed through a form,
' so I'm getting them through "request"
npID = trim(request("npID"))
' has to be an integer, so let's convert it to be sure
npID = CInt(npID)
npAS = trim(request("npAS"))
' has to be an integer, so let's convert it to be sure
npAS = CInt(npAS)
|
|
 |