Problem with access database, and VB .NET

A

amit

Hi guys I am trying to use select Query with Like operator

Select DrugName from Stock where (DrugName LIKE '*s*')

This query works in MS-Access Query option and returns some records,
but when I run it through VB .net programm it dosen't return any result
nither it gives any error.

What could be the problem plz. help
 
R

Ron Weiner

Try changing the Sql to

Select DrugName from Stock where DrugName LIKE '%s%'
 
B

Brian Cryer

amit said:
Hi guys I am trying to use select Query with Like operator

Select DrugName from Stock where (DrugName LIKE '*s*')

This query works in MS-Access Query option and returns some records,
but when I run it through VB .net programm it dosen't return any result
nither it gives any error.

What could be the problem plz. help

What error do you get?

Can you show your code?
 
A

amit

Hello

Thanks for the reply

I tried using '%s%' instade of '*s*'

There are two records starting with 's' but is returns only one.


Thanks
 
P

Paul Clement

¤ Hello
¤
¤ Thanks for the reply
¤
¤ I tried using '%s%' instade of '*s*'
¤
¤ There are two records starting with 's' but is returns only one.

I would double-check your results. I'm not sure how you are displaying the data in order to verify
that only one instance is being returned, but there is no reason it would work for one row and not
another.

Also, I would remove the parentheses around your WHERE statement. They are unnecessary.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
A

amit

Hello Paul

I double checked it,
I tried the same with %d%, there are 5 records starting with d it shows
only 4...
It eleminates the first maching record in every case, what could be the
reason?
Plz help

The code is

ocmEmpresas.CommandText = "Select DrugName from Stock where (DrugName
LIKE '%" + TextBox2.Text.Trim() + "%')"

Thanks
 
P

Paul Clement

¤ Hello Paul
¤
¤ I double checked it,
¤ I tried the same with %d%, there are 5 records starting with d it shows
¤ only 4...
¤ It eleminates the first maching record in every case, what could be the
¤ reason?
¤ Plz help
¤
¤ The code is
¤
¤ ocmEmpresas.CommandText = "Select DrugName from Stock where (DrugName
¤ LIKE '%" + TextBox2.Text.Trim() + "%')"
¤

How are you viewing the data? Did you check all the rows in the Recordset?


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top