Problem with access database, and VB .NET

  • Thread starter Thread starter amit
  • Start date Start date
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
 
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?
 
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
 
¤ 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)
 
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
 
¤ 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)
 
Back
Top