Results 1 to 9 of 9

Thread: sql problem

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    sql problem

    I know this is not really a vb.net problem
    but since i will be using the query in my program...

    Anyway when i run this query in the picture below i don't get any result, when i should be getting one result. I just don't get what i'm doing wrong

    Thanx a lot
    Attached Images Attached Images  

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: sql problem

    Ok - let's make sure we don't have some silly problem - like wrong DB open or something like that...

    Will this work?

    Select * from tblKlant Where KlantNaam='Peeters'

    If so will this then work?

    Select * from tblKlant Where Left(KlantNaam,3)='Pee'

    What is the datatype of that column - some datatypes will not work with the LIKE operator...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    Re: sql problem

    Jup they both work
    It's a regular text field.

    I just don't se what i'm doing wrong, the like looks good to me..but no result

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: sql problem

    Quote Originally Posted by spoofer
    Jup they both work
    It's a regular text field.
    Ok - is this MS SQL SERVER as the backend database...

    And you mean the datatype is TEXT (as opposed to VARCHAR or CHAR)...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    Re: sql problem

    It's just MS Access database

    Hope you can help me, thx

  6. #6
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: sql problem

    Is this being done in Access or VB and the query is being run against access? If completely in MS Access then you need to replace the normal SQL wild card character ( % ) with the Access wild card character ( * ).
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    Re: sql problem

    haha thanx Gary
    I knew it was something small

  8. #8

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    Re: sql problem

    Ok now i got the previous thing working i got a follow up question:
    I wanted to use the query in my program

    VB Code:
    1. objData.SQL = "sp_ZoekKlantOpNaam"
    2.                 objData.InitializeCommand()
    3.                 objData.AddParameter("@KlantNaam", Data.OleDb.OleDbType.VarChar, txtZoekKlant.Text.Length, _
    4.                    "*" & txtZoekKlant.Text & "*")
    5.                 objData.OpenConnection()
    6.                 objData.DataReader = objData.Command.ExecuteReader

    The addparameter is just a functions that grabs the content of the textbox and passes it to the query, this works fine, used it lots of times in my project.

    So whan i entered *pee* in Acces i got a result from the query. Now when i do basicly the same but then from vb i get nothing

    I also tried replacing * with % without any luck

    Hope someone can help me

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2006
    Posts
    38

    Re: sql problem

    nvm worked around this, just created the query in vb

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