Impossibilité de lancer une requête SQL

Fermé
hilario33 - 12 janv. 2010 à 14:59
joomliner Messages postés 89 Date d'inscription jeudi 9 juin 2011 Statut Membre Dernière intervention 1 août 2016 - 3 juil. 2011 à 07:54
Bonjour,
Dans un script AutoIt, je dois lancer une requête SQL sur une base informix distante. J'ai une erreur au lancement de la requête. Voici le code écrit :


Code
LECTURE DU FICHIER .INI
$dsn = IniRead($cfg_file, "infocentre", "dsn", "")
$host = IniRead($cfg_file, "infocentre", "host", "")
$server = IniRead($cfg_file, "infocentre", "server", "")
$service = IniRead($cfg_file, "infocentre", "service", "")
$protocol = IniRead($cfg_file, "infocentre", "protocol", "")
$database = IniRead($cfg_file, "infocentre", "database", "")
$uid = IniRead($cfg_file, "infocentre", "uid", "")
$pwd = IniRead($cfg_file, "infocentre", "pwd", "")

$objConn = ObjCreate("ADODB.Connection")

$objConn.Open("Dsn=" & $dsn & ";Host=" & $host & ";Server=" & $server & ";Service=" & $service & ";Protocol=" & $protocol & ";Database=" & $database & ";Uid=" & $uid & ";Pwd=" & $pwd)

$rsCustomers = $objConn.Execute("select distinct s_grp_trv_3.nide,s_grp_trv_3.nprt from s_grp_trv s_grp_trv_3 where (s_grp_trv_3.nide ='" & $entrep_en & "') and ((s_grp_trv_3.nprt LIKE "'GPE%'")or(s_grp_trv_3.nprt LIKE "'RE%'")or(s_grp_trv_3.nprt LIKE "'S%'")"))


La variable $entrep_en a bien été déclarée.

J'ai l'erreur suivante :

---------------------------
AutoIt Error
---------------------------
Line 156 (File "D:\AutoIt\sadf\sadf.au3"):

$rsCustomers = $objConn.Execute("select distinct s_grp_trv_3.nide,s_grp_trv_3.nprt from s_grp_trv s_grp_trv_3 where (s_grp_trv_3.nide ='" & $entrep_en & "') and (s_grp_trv_3.nprt LIKE "'GPE%'")or(s_grp_trv_3.nprt LIKE "'RE%'")or(s_grp_trv_3.nprt LIKE "'S%'")")
$rsCustomers = $objConn.Execute(^ ERROR

Error: Error in expression.
---------------------------
OK
---------------------------
ES-ce le code de ma requête qui comporte une anomalie ?
J'avoue que je séche. Pouvez-vous m'apporter une aide.
Merci.

Cordialement

1 réponse

joomliner Messages postés 89 Date d'inscription jeudi 9 juin 2011 Statut Membre Dernière intervention 1 août 2016 36
3 juil. 2011 à 07:54
Le problème est dans la gestion des apostrophes et guillemets et concaténation de chaine. Il y a un conflit.

Vérifiez la requête!

0