Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Working with ODBC..
Message
De
27/04/2009 09:26:01
 
 
À
27/04/2009 06:01:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01396459
Message ID:
01396486
Vues:
78
The string concatenation in this line does not work:

> n = sqlexec(h,[Select * From ] + m.lctable,m.lctable2+ [ WHERE INT(VAL(lcTable.imageid))=lcTable2.ID;
> AND lcTable.Nomber LIKE '%99%'],'temp')

The SQLExec line in the previous example was quite short, for a longer statement I'd suggest to use Text/EndText for better readability, e.g.:
Local lcSQL
Text To lcSQL NoShow
Select * 
    From data, pictures 
    Where Int(Val(data.imageID)) = pictures.id 
        And data.nomber Like ?p1
EndText

Local p1
p1 = '%99%'
n = sqlexec(h,m.lcSQL, 'yourResultCursor')
hth
-Stefan



>Hi
>Sorry for intermeddling
>
>I have to retrieve data from active access database with variable criteria.
>The ACCESS tables name is 'data' and 'pictures' while data.imageid=pictures.id and unfortunately pictures.id is integer and data.imageid is string (The access is not my project and I cannot change it).
>I get error 232 ("TEMP" is not an array (Error 232)) on the following code:
>local llok, lcerrormessage 
>llok = .t.
>lcerrormessage = ""
>local lcmdb
>if m.llok
>	lcmdb = getfile('mdb')
>	llok = file(m.lcmdb,1)
>	lcerrormessage = ""
>endif
>
>local lcconnectionstring, h
>if m.llok
>	lcconnectionstring = ;
>		"DRIVER=Microsoft Access Driver (*.mdb);" + ;
>		"DBQ=" + justfname(m.lcmdb) + ";" + ;
>		"DefaultDir=" + justpath(m.lcmdb) + ";" + ;
>		"DriverId=25;FIL=MSAccess;MaxBufferSize=2048;PageTimeout=5"
>	h = sqlstringconnect(m.lcconnectionstring)
>	llok = ( h > 0 )
>	if !m.llok
>		lcerrormessage = getlasterror()
>	endif
>endif
>
>local n
>
>local lctable,lctable2
>if m.llok
>	lctable = 'data' && whatever your specs say
>	lctable2='pictures'
>	n = sqlexec(h,[Select * From ] + m.lctable,m.lctable2+ [ WHERE  INT(VAL(lcTable.imageid))=lcTable2.ID;
>   AND  lcTable.Nomber LIKE '%99%'],'temp')
>	llok = ( n > 0 )
>	if !m.llok
>		lcerrormessage = getlasterror()
>	endif
>endif
>if m.llok
>	browse
>endif
>
>try
>	sqldisconnect(h)
>catch
>endtry
>if !m.llok and !empty(m.lcerrormessage)
>	messagebox(m.lcerrormessage,48)
>endif
>return
>
>function getlasterror()
>	local lcmessage, laerror[1]
>	lcmessage = ""
>	aerror(laerror)
>	if type('laError[2]') = 'C'
>		lcmessage = laerror[2]
>	endif
>
>	return m.lcmessage
>endfunc
>tHANKS
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform