[VBS] Select sur base SQL
Bonjour,
J'utilise une base SQL via PhpMyAdmin pour autoriser la connexion réseau d'imprimantes par rapport au nom des postes.
La base est faite de cette manière:
192.168.xx.xx/localhost/locationposte/location
- locationposte
- - - location
- - - - - Colonnes
- - - - - - - - DefaultPrinter
- - - - - - - - 2ndPrinter
- - - - - - - - 3rdPrinter
- - - - - - - - 4thPrinter
- - - - - - - - 5thPrinter
- - - - - - - - ClientName
- - - - - Index
- - - - - - - - ClientName
A l'aide de la requête suivant, je récupère les postes qui utilisent une imprimante.
Code:
1 2 3 4 5 6 7
| SELECT *
FROM location
WHERE ( `DefaultPrinter` LIKE '%lonspruacaseca%')
OR ( `2ndPrinter` LIKE '%lonspruacaseca%')
OR ( `3rdPrinter` LIKE '%lonspruacaseca%')
OR ( `4thPrinter` LIKE '%lonspruacaseca%')
OR ( `5thPrinter` LIKE '%lonspruacaseca%') |
J'aimerais simplifier la tâche par un script VB via un inputbox par exemple!
Voilà ce que j'ai commencé:
Code:
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
| dim objCon
dim strCon
dataSource = "192.168.xx.xx"
initialCatalog = "locationposte"
tableName = "location"
columnName = "DefaultPrinter"
columnName2 = "2ndPrinter"
columnName3 = "3rdPrinter"
columnName4 = "4thPrinter"
columnName5 = "5thPrinter"
'Index = ClientName
userId = " " 'Nom d'utilisateur
password = " " 'mot de passe
'Connection
Set objCon = CreateObject("ADODB.Connection")
'Authentication
objCon.ConnectionString = "DRIVER={MySQL ODBC 5.3 ANSI Driver}; SERVER=" & dataSource & _
"; PORT=3306;" & _
"DATABASE=" & initialCatalog & _
"; USER=" & userId & _
"; PASSWORD=" & password & _
"; OPTION=3;"
objCon.Open
strCon = "SELECT * FROM " & Tablename & "WHERE" & columnName & "or" & columnName2 & "or" & columnName3 & "or" & columnName4 & "or" & columnName5 |
Je ne suis pas très à mon aise, un peu d'aide svp?