|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > LIKE behaves differently in VB |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|