473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with access database, and VB .NET

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

Oct 4 '06 #1
7 1065
Try changing the Sql to

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

--
Ron W
www.WorksRite.com
"amit" <am***********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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

Oct 4 '06 #2
Use % instead of *....

--

"amit" <am***********@gmail.coma écrit dans le message de news:
11**********************@i3g2000cwc.googlegroups.c om...
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

Oct 4 '06 #3
"amit" <am***********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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
Oct 4 '06 #4
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

Oct 4 '06 #5
On 4 Oct 2006 04:43:58 -0700, "amit" <am***********@gmail.comwrote:

¤ 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)
Oct 4 '06 #6
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:
On 4 Oct 2006 04:43:58 -0700, "amit" <am***********@gmail.comwrote:

¤ 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 wouldwork for one row and not
another.

Also, I would remove the parentheses around your WHERE statement. They are unnecessary.
Paul
~~~~
Microsoft MVP (Visual Basic)
Oct 5 '06 #7
On 5 Oct 2006 02:14:06 -0700, "amit" <am***********@gmail.comwrote:

¤ 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)
Oct 5 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Wayne Wengert | last post by:
I am using VS.NET 2003, VB.NET, ADO.NET and an Access 2000 database. I want to display a list of all tables in an Access database. I want to put that list of table names in a listbox so the user...
9
by: Pacific Design Studios | last post by:
I'm running ASP on IIS 5. My users who are on the network can access our database. Any users from the internet "outside" the network can't access it. We don't have a firewall. Our Windows Server...
3
by: Dave | last post by:
Hey, I'm running a localhost web server...W2K with IIS 5.0, and I'm trying to use ASP/ADO to access my Access database. When I first load the page, everything works, but if i hit refresh (F5 or...
7
by: Graham Taylor | last post by:
I've tried posting this in the 'microsoft.public.access' but I will post it here also, as I think it might be the webserver which is causing my problem. --------- I have an Access 2003 database...
2
by: Robert McGregor | last post by:
Hi all, I've got a Front End / Back End database that was working just fine. One day i opened the FE to find that if I tried to open one of the linked tables from the database window, nothing...
5
by: lappy | last post by:
Hello, I have written a small programme to compact an access 97 database. Dim je As New JRO.JetEngine ' Compacts database Data.Mdb to Data2.mdb. je.CompactDatabase...
1
by: Tom Wild | last post by:
Hi I am trying to create a webform that connects to an Access database. If I use the connection string: "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Gizmo\Gizmo.mdb" Then the application...
2
by: shapper | last post by:
Hello, I added some profile properties to my web.config file. Then I started to use my profile properties in a page class and I get an error: An error has occurred while establishing a...
1
by: kkrizl | last post by:
I've tried to research this problem, and I haven't been able to find any references to it. Probably because I shouldn't be doing it, but it was working, and now it's not. I'm trying to develop a...
0
by: JACompute | last post by:
I have an invoicing system that uses a VB6 program to post new invoice entries to a centralized Vendor management system (also in VB6), via a Web server and some ASP code. The system has been in...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.