Results 1 to 7 of 7

Thread: [RESOLVED] Problem with SQL statement

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Resolved [RESOLVED] Problem with SQL statement

    Hi guys,

    (Using .net cf 2.0)

    I have the following sql statement:
    VB Code:
    1. With sqlCmd
    2.             .CommandText = "SELECT count(*) FROM photos WHERE photoLocation LIKE '" & H42_PHOTO_DIRECTORY & "%'"
    3.             '.Parameters.Add(New SqlCeParameter("@photoLocation", H42_PHOTO_DIRECTORY & "%"))
    4.             Dim assigned As Integer = .ExecuteScalar
    5.             MsgBox(assigned)
    6.             '.Parameters.Clear()
    7.         End With

    But it always returns 0 when i know that it shouldn't
    (by the way H42_PHOTO_LOCATION is a folder on my Pocket PC.) I need it if possible to be done using parameters. Can anybody tell me why this isn't working?

    Thanks in advance for any help
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  2. #2
    Lively Member
    Join Date
    Nov 2006
    Posts
    116

    Re: Problem with SQL statement

    It depends on the database use, some database use % and some use * as wildcard.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Problem with SQL statement

    Ok....didn't know that...i'll try it and let you know.
    Thanks
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Problem with SQL statement

    No it still returns 0 all the time!
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: Problem with SQL statement

    Managed to fix it.
    Thanks for your help though.

    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

  6. #6
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: [RESOLVED] Problem with SQL statement

    You should post your fix to the problem so anyone else facing the same issues can find it with a search.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Posts
    734

    Re: [RESOLVED] Problem with SQL statement

    There wasn't a problem with the code....i found out that i guy i'm working on this project with (who isn't in work today) changed the folder and the text in photoLocation....so i was searching using the wrong comparison.
    If your problem has been solved then please mark the thread [RESOLVED].
    If i have helped then please Rate my post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width