[thelist] Pass ASP query sting to SQL statement

Taurus James taurus_james at yahoo.com
Sat Aug 11 07:30:51 CDT 2007

Hi Dave,
1. You need to validate vidid. Use something like: (I'm assuming it is numeric)

if isNumeric(vidid) then
    ' continue page processing
    ' display error message (invalid id)

2. Your query needs to be more like:
"SELECT [SPECIFIC FIELD1], [SPECIFIC FIELD2], [ETC.] FROM videos where active='yes' and Id=" & vidid

Good practice is to specify the fields to return (you don't need the caps or the []). Pulling back unnecessary fields means wasted resources.  Also, I think you need single quotes around the "yes", or you may be able to substitute a 1 or 0 without quotes. Check the active field data type in your database. If the vidid is numeric as I assume, then you don't need single quotes, but you do need the " & because the vidid is a variable.

3. I want to say the recordset connection code looks suspect, but it's been a long time since I've done Access. Try fixing the first two points above and see if they clear up the DB error. I think the error you see is because the query is invalid. Try executing the query within Microsoft Access, substituting the vidid. I will say that the error "Appears" to be complaining about the "source" property. I've never used it. Keep in mind that your version of ADO may not support this property. Try this:

dim strSQL
strSQL = "SELECT [SPECIFIC FIELD1], [SPECIFIC FIELD2], [ETC.] FROM videos where active='yes' and Id=" & vidid

...and then...


Groups at beachcomp.com wrote: I have 
vidid = request.querystring("id")
MY_STRING = "Driver={Microsoft Access Driver (*.mdb)};DBQ= videos.mdb"
Server.ScriptTimeout = 180
Dim videos
Set videos = Server.CreateObject("ADODB.Recordset")
videos.ActiveConnection = MY_STRING
videos.Source = "SELECT * FROM videos where active=Yes and Id='vidid'"
videos.CursorType = 1
videos.CursorLocation = 1
videos.LockType = 1

But I get:

Microsoft OLE DB Provider for ODBC Drivers error '80040e21' 

ODBC driver does not support the requested properties. 

 Taurus M. James

Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 

More information about the thelist mailing list