|
-
Apr 13th, 2007, 04:42 AM
#1
Thread Starter
Addicted Member
SQL problem
Hi All,
I am using VB6 and connecting to my DB using DAO
I am trying to create a search wherby a user would input say 3 letters in to a textbox and the resulting matches would populate a msflexgrid.
For example, if he types in 'sic', then this would find 'basic force gauge' from the gauges table.
I have used the code below and although i have used the Like command, the search brings up 0 records. Yet i know that there several matches to the query.
Can you have a look at the query. I'm sure this is where the problem is, but not sure how to correct6
Many Thanks
strSQL = "Select Instrumentdescription, Instrumennumber From GAUGES where Instrumentdescription Like '" & Text1.Text & "'"
Data1.RecordSource = strSQL
Data1.Refresh
Data1.UpdateControls
-
Apr 13th, 2007, 04:55 AM
#2
Fanatic Member
Re: SQL problem
You have't added wildcards, try:
Code:
strSQL = "Select Instrumentdescription, Instrumennumber From GAUGES where Instrumentdescription Like '%" & Text1.Text & "%'"
-
Apr 13th, 2007, 05:00 AM
#3
Thread Starter
Addicted Member
Re: SQL problem
Hi Davebat,
That was my mistake. In my project i have got the wildcards. I quickly typed in the code here and ommited the wildcards by mistake.
Even with the wildcards i get no results back.
-
Apr 13th, 2007, 05:12 AM
#4
Re: SQL problem
try this...
vb Code:
strSQL = "Select Instrumentdescription, Instrumennumber From GAUGES where Instrumentdescription Like '*" & Text1.Text & "*'"
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
-
Apr 13th, 2007, 05:52 AM
#5
Re: SQL problem
What DB are you using? Different DBs use different wildcards. If it's access you want the * that Ganeshmoorthy suggested. For SQL Server you use %. Other DB's use different wild cards again but most use one of these two characters.
-
Apr 13th, 2007, 07:34 AM
#6
Re: SQL problem
All DB use the % sign for wildcards. Even Access if you are preforming the seach though ADO from VB.
Please post the exact SQL string that is being passed from the application to the DB.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Apr 13th, 2007, 07:56 AM
#7
Thread Starter
Addicted Member
Re: SQL problem
Thanks Ganeshmoorthy,
The code you suggested has fixed the problem.
Many Thanks
-
Apr 15th, 2007, 11:00 PM
#8
Re: SQL problem
sparkash: You are most welcome and thanks for your rep points...
If an answer to your question has been helpful, then please, Rate it!
Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.
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
|