October 25th, 2003, 06:44 AM
Problem with SELECT query with WHERE clause
For some reason since migrating to a MS SQL database the following always returns no results:
'Open a recorset to check whether or not filename is already in use
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = MM_archantInsight_STRING
objRS.Source = "SELECT * FROM tblImages WHERE filename LIKE '" & filename & "'"
objRS.CursorType = 0
objRS.CursorLocation = 2
objRS.LockType = 1
It's to check that there's not already an image with a given name in the database, but I know there is, yet still always returns objRS.recordcount = -1
This worked ok in Access, so I am at a loss.
October 25th, 2003, 07:11 AM
Try ... LIKE '%"&filename&"%'
October 25th, 2003, 07:29 AM
I've actually managed to fix it now by using the following, as I had done with access before:
strSQL = "SELECT * FROM tblImages WHERE filename = '" & filename & "'"
Set objRS = Server.CreateObject("ADODB.RecordSet")objRS.Open strSQL, dbConn, 1,3
Thanks for your help!