value not found in sql query

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

value not found in sql query

Post by sal21 »

Piece of code:

Code: Select all


RAPPORTO = Trim(Format(GAF_RS(1), "#0000")) & Format(Right(GAF_RS(2), 7), "#00000000")
RAPPORTO = Format(RAPPORTO, "00000000000")

'ACCORDATO_TOT
'UTILIZZATO_TOT
'IMP_RACCOLTA_TOTALE
'CTA_MargineIntermediazioneLordo
'DATA_MART_RS.Find "NDG = " & RAPPORTO
'DATA_MART_RS.Find "NDG = '" & RAPPORTO & "'", , adSearchForward, 1

strSQL = "SELECT * FROM CC_DAILY WHERE RAPPORTO = '" & RAPPORTO & "'"
Set CC_DAILY_RS = GAF_CONN.Execute(strSQL)
Debug.Print strSQL
If Not CC_DAILY_RS.EOF Then

i use this code to find RAPPORTO.
But the code not match value?????

In debug.print windows i have:
SELECT * FROM CC_DAILY WHERE RAPPORTO = '10000000014'

And i think the query search a numeric value not a string?

note:
The var RAPPORTO is dimensioned As String.
Rhe filed RAPPORTO is text format.

I think instead = '10000000014' i need = "10000000014" to match the value in column RAPPORTO, or not?

User avatar
HansV
Administrator
Posts: 78446
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: value not found in sql query

Post by HansV »

Single quotes ' are fine in SQL, so that is not the problem.

Right(GAF_RS(2), 7) will be at most 7 characters in length, but Format(Right(GAF_RS(2), 7), "#00000000") will expand this to exactly 8 characters by adding leading zeros. Is that what you intend?

And are you absolutely sure that 10000000014 occurs in the RAPPORTO field?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4353
Joined: 26 Apr 2010, 17:36

Re: value not found in sql query

Post by sal21 »

TKS! resolved, arround ....

be at most 7 characters in length, but Format(Right(GAF_RS(2), 7), "#00000000")