#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    19
    Rep Power
    0

    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

    Dim objRS

    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
    objRS.Open

    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.

    Please help!
  2. #2
  3. Modding: Oracle MsSQL Firebird
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2001
    Location
    Outside US
    Posts
    8,527
    Rep Power
    539
    Try ... LIKE '%"&filename&"%'
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    19
    Rep Power
    0
    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!

IMN logo majestic logo threadwatch logo seochat tools logo