Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 28th, 2008, 04:40 PM
ulynen ulynen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 ulynen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 46 sec
Reputation Power: 0
LIKE behaves differently in VB

This is a simple query using LIKE to match a date string of a particular format.
SELECT [Patient Notes].Note
FROM [Patient Notes]
WHERE ((([Patient Notes].Note) Like "*##-##-####*"));
In Access this returns 193 records correctly; however, if I execute the same query using ADO from VB6 using a SQL string it returns no records.

strsql = "SELECT [Patient Notes].Note "
strsql = strsql & "FROM [Patient Notes] "
strsql = strsql & "WHERE ((([Patient Notes].Note) Like ""*##-##-####*""));"

Set rsList = New ADODB.Recordset
rsList.Open strsql, Connection, adOpenKeyset, adLockOptimistic

Any ideas.
I need to use the query in VB because I can't always get to the database on the client machine.
Uwe

Reply With Quote
  #2  
Old April 30th, 2008, 04:50 PM
dykebert's Avatar
dykebert dykebert is online now
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 347 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 10 h 41 m 29 sec
Reputation Power: 1
well the simple solution would be to simply store the query that works in the DB and then call the query from VB

strSql = "SELECT Note "
strSql = strSql & "FROM [Patient Notes Query] "

rstList.open, strsql, Connection

The only other thing I can thing of is to step through the code and check the value of strSql. Maybe even just do a plain select against the table to make sure your connection etc are all OK.

Reply With Quote
  #3  
Old April 30th, 2008, 10:55 PM
ulynen ulynen is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 ulynen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 46 sec
Reputation Power: 0
I tried that already. It seems that LIKE doesn't work well in SQL for Access when called from VB. I had a similar problem before and ended up using multiple instr calls.
In this instance I must do a pattern match.
You may be right in that I'll have to use a stored procedure.
Uwe

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > LIKE behaves differently in VB


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT