Home All Groups Group Topic Archive Search About

Problem with access database, and VB .NET

Author
4 Oct 2006 10:31 AM
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

Author
4 Oct 2006 10:49 AM
Ron Weiner
Try changing the Sql to

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

Show quoteHide quote
"amit" <amit.mural***@gmail.com> wrote in message
news:1159957895.583596.216140@i3g2000cwc.googlegroups.com...
> 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
>
Author
4 Oct 2006 10:52 AM
Patrice
Use % instead of *....

--

"amit" <amit.mural***@gmail.com> a écrit dans le message de news:
1159957895.583596.216***@i3g2000cwc.googlegroups.com...
Show quoteHide quote
> 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
>
Author
4 Oct 2006 11:43 AM
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
Author
4 Oct 2006 1:10 PM
Paul Clement
On 4 Oct 2006 04:43:58 -0700, "amit" <amit.mural***@gmail.com> wrote:

¤ 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)
Author
5 Oct 2006 9:14 AM
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


Paul Clement wrote:
Show quoteHide quote
> On 4 Oct 2006 04:43:58 -0700, "amit" <amit.mural***@gmail.com> wrote:
>
> ¤ 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)
Author
5 Oct 2006 3:38 PM
Paul Clement
On 5 Oct 2006 02:14:06 -0700, "amit" <amit.mural***@gmail.com> wrote:

¤ 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)
Author
4 Oct 2006 10:52 AM
Brian Cryer
"amit" <amit.mural***@gmail.com> wrote in message
news:1159957895.583596.216140@i3g2000cwc.googlegroups.com...
> 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?
--
Brian Cryer
www.cryer.co.uk/brian