Bonjour,
Je voudrais faire une requête en ASP qui va taper sur plusieurs bases access qui sont dans des DSN différents. Est ce possible ?
Voici ma première requête
<%
Set obj_datevoul = Server.CreateObject("ADODB.Recordset")
obj_datevoul.Activeconnection= "DSN=materiel"
requete = "SELECT DISTINCT CodeChant FROM mouvmat WHERE (DateDiff('d', DateEnl, '"&datevoul1&"') >=0 AND (DateRet IS NULL OR DateDiff('d', DateRet, '"&datevoul1&"') <= 0)) OR (DateDiff('d', DateEnl, '"&datevoul1&"') <= 0 AND DateDiff('d', DateEnl, '"&datevoul2&"') >= 0) ORDER BY CodeChant "
obj_datevoul.source= requete
obj_datevoul.cursortype = 0
obj_datevoul.cursorlocation = 2
obj_datevoul.locktype = 3
obj_datevoul.Open
obj_datevoul_numrows=0
%>
Voici ma deuxième requête
<%
Set objrs3 = Server.CreateObject("ADODB.Recordset")
objrs3.Activeconnection= "DSN=batig"
requete3 = "SELECT code, codechantier, codefou, datecmd, totalht from cmdfou where codechantier='"&numauto&"' and (datediff('d',datecmd,'"&datevoul1&"')<=0 and datediff('d',datecmd,'"&datevoul2&"')>=0) and code not in (select code from cmdfouligne where libelle like '%benne%')"
objrs3.source= requete3
objrs3.cursortype = 0
objrs3.cursorlocation = 2
objrs3.locktype = 3
objrs3.Open
objrs3_numrows=0
%>
et en fait, je voudrais faire un union entre ces 2 requêtes (pour recouper les mêmes codes chantier)
et cette requête ne marche pas, ça me dit qu'il ne reconnait pas la table cmdfou (je pense qu'il n'aime pas dsn=materiel;batig ... j'ai essayé aussi dsn=materiel,batig mais sans succès)
<%Set obj_datevoul = Server.CreateObject("ADODB.Recordset")
obj_datevoul.Activeconnection= "DSN=materiel;batig"
requete = "SELECT DISTINCT CodeChant FROM mouvmat WHERE (DateDiff('d', DateEnl, '"&datevoul1&"') >=0 AND (DateRet IS NULL OR DateDiff('d', DateRet, '"&datevoul1&"') <= 0)) OR (DateDiff('d', DateEnl, '"&datevoul1&"') <= 0 AND DateDiff('d', DateEnl, '"&datevoul2&"') >= 0) ORDER BY CodeChant UNION SELECT code, codechantier, codefou, datecmd, totalht from cmdfou where codechantier='"&numauto&"' and (datediff('d',datecmd,'"&datevoul1&"')<=0 and datediff('d',datecmd,'"&datevoul2&"')>=0) and code not in (select code from cmdfouligne where libelle like '%benne%')"
obj_datevoul.source= requete
obj_datevoul.cursortype = 0
obj_datevoul.cursorlocation = 2
obj_datevoul.locktype = 3
obj_datevoul.Open
obj_datevoul_numrows=0
%>
Qqun a t'il une idée ?
Merci.
Partager