Jan 11th, 2007, 07:44 AM
#1
Thread Starter
Member
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
Jan 11th, 2007, 08:05 AM
#2
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...
Jan 11th, 2007, 08:12 AM
#3
Thread Starter
Member
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
Jan 11th, 2007, 08:25 AM
#4
Re: sql problem
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)...
Jan 11th, 2007, 08:26 AM
#5
Thread Starter
Member
Re: sql problem
It's just MS Access database
Hope you can help me, thx
Jan 11th, 2007, 08:41 AM
#6
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
Jan 11th, 2007, 08:42 AM
#7
Thread Starter
Member
Re: sql problem
haha thanx Gary
I knew it was something small
Jan 11th, 2007, 09:31 AM
#8
Thread Starter
Member
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:
objData.SQL = "sp_ZoekKlantOpNaam"
objData.InitializeCommand()
objData.AddParameter("@KlantNaam", Data.OleDb.OleDbType.VarChar, txtZoekKlant.Text.Length, _
"*" & txtZoekKlant.Text & "*")
objData.OpenConnection()
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
Jan 11th, 2007, 10:50 AM
#9
Thread Starter
Member
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
Forum Rules
Click Here to Expand Forum to Full Width