|
 |
asp_databases thread: on/off in sql query
Message #1 by "Michael Goldman" <mg188@h...> on Fri, 20 Oct 2000 21:01:15 -0700
|
|
Hi All,
Having trouble with using "on/off" data type in Access97.
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
/mg53rev1/test.asp, line 66
Here's the code snippet:
StrIns = "Insert into tblItem (ItemID, PersID, Status"
strVal = "Values('" &CStr(Request.Form("ItemID"))&
"','"&ors("PersID")&"',on"
objCmd.CommandText = strIns & ") " & strVal & ")"
objCmd.Execute
(the last line is line 66)
In the db, the Status field is set to data type yes/no with it's format set
to on/off.
Where did I screw up?
Happy Trails
Message #2 by "Arbon Reimer" <arbon_reimer@h...> on Sat, 21 Oct 2000 20:58:35 -0600
|
|
I have had good luck using 1 or 0 for "bit" type fields.
If the person's status is a variable carried from somewhere else on the
page, you can convert the variable data type to Boolean with the CBool()
function... that way the "on/off" or "yes/no" or "1/0" or "true/false"
ambiguities are eliminated. Give this a shot:
strVal = "Values('" &CStr(Request.Form("ItemID"))&
"','"&ors("PersID")&"', 1"
OR
strVal = "Values('" &CStr(Request.Form("ItemID"))&
"','"&ors("PersID")&", " & CBool(status) & ")"
Regards,
-Arbon
Hi All,
Having trouble with using "on/off" data type in Access97.
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria
expression.
/mg53rev1/test.asp, line 66
Here's the code snippet:
StrIns = "Insert into tblItem (ItemID, PersID, Status"
strVal = "Values('" &CStr(Request.Form("ItemID"))&
"','"&ors("PersID")&"',on"
objCmd.CommandText = strIns & ") " & strVal & ")"
objCmd.Execute
Message #3 by "peter" <ph@t...> on Thu, 26 Oct 2000 01:15:21 +0100
|
|
the error is in the sql, even though its positioned at the .execute
line..basically you need to convert the variable to a Boolean with CBool()
cheers
peter
|
|
 |