1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
' =================== '
' Bloc 1 '
' =================== '
' Connexion à la base de donnée
Set conn = Server.CreateObject("ADODB.Connection")
connstring = "driver={SQL Server};server=localhost;uid=sao;pwd=passe;database=I_SAO"
conn.open connstring
' =================== '
' Bloc 2 '
' =================== '
' Variables : chaine
dim strNom, strDateDeb, strDateFin, strStructure, strDateDebTemp, strDateFinTemp
dim arDateDeb, arDateFin, intJourDeb, intJourFin, intMoisDeb, intMoisFin, intAnneeDeb, intAnneeFin
' Variable : entier
dim intFlag
' =================== '
' Bloc 3 '
' =================== '
infFlag = 0
'test du champ nom
if Request.QueryString("chNom")<>"" then
strNom = "WHERE ORG_UserOrg LIKE '%"&Request.QueryString("chNom")&"%'"
intFlag = 1
else
strNom = ""
end if
'test du champ datedeb
if Request.QueryString("chDateDeb")<>"" then
strDateDebTemp = Request.QueryString("chDateDeb")
arDateDeb = split(strDateDebTemp,"/",-1,1)
intJourDeb = arDateDeb(0)
intMoisDeb = arDateDeb(1)
intAnneeDeb = arDateDeb(2)
if intFlag = 1 then
strDateDeb = " AND ORG_DateCreat >= '"&dateValue(strDateDebTemp)&"'"
else
strDateDeb = "WHERE ORG_DateCreat >= '"&dateValue(strDateDebTemp)&"'"
intFlag = 1
end if
else
strDateDeb = ""
end if
'test du champ datefin
if Request.QueryString("chDateFin")<>"" then
strDateFinTemp = Request.QueryString("chDateFin")
arDateFin = split(strDateFinTemp,"/",-1,1)
intJourFin = arDateFin(0)
intMoisFin = arDateFin(1)
intAnneeFin = arDateFin(2)
if intFlag = 1 then
strDateFin = " AND ORG_DateCreat <= '"&dateValue(strDateFinTemp)&"'"
else
strDateFin = "WHERE ORG_DateCreat <= '"&dateValue(strDateFinTemp)&"'"
intFlag = 1
end if
else
strDateFin = ""
end if
'test du champ structure
if Request.QueryString("chStructure")<>"" AND Request.QueryString("chStructure")<>"0" then
if intFlag = 1 then
strStructure = " AND ORG_CodeStructure_FK = '"&Request.QueryString("chStructure")&"'"
else
strStructure = "WHERE ORG_CodeStructure_FK = '"&Request.QueryString("chStructure")&"'"
intFlag = 1
end if
else
strStructure = ""
end if
' =================== '
' Bloc 4 '
' =================== '
'Requête SQL généré en fonction de la recherche
sql = "SELECT ORG_UserOrg,ORG_DateCreat, ORG_CodeStructure_FK FROM PSO_ORGANISME "&strNom&strDateDeb&strDateFin&strStructure&""
sql2 = "SELECT COUNT(*) AS res FROM PSO_ORGANISME "&strNom&""&strDateDeb&""&strDateFin&""&strStructure&""
Conn.execute sql |
Partager