Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2523 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  probleme script vbs

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

probleme script vbs

n°1426104
donny3
Posté le 16-08-2006 à 15:44:33  profilanswer
 

salut,
 
J'essai de creer un script vbs qui me permette à partir d'un fichier csv d'en creer un autre qui contienne un script sql pour creer des tables;
un exemple
 
fichier.csv

Citation :


champ1 table1 type taille
champ2 table1 type taille
champ1 table2 type taille
champ2 table2 type taille


 
et je voudrais en sortie

Citation :


create table table1 (champ1 type(taille),champ2 type(taille));
create table table2 (champ1 type(taille),champ2 type(taille));


 
 
voici mon code
 

Code :
  1. 'déclaration file system object
  2. Dim fso
  3. 'déclaration file system object
  4. Dim fso1
  5. 'instanciation
  6. Set FSO = CreateObject("Scripting.FileSystemObject" )
  7. 'instanciation
  8. Set FSO1 = CreateObject("Scripting.FileSystemObject" )
  9. 'on instance le fichier texte
  10. Set Ftxt = FSO.OpenTextFile("C:\Documents and Settings\1.txt" )
  11. 'on instance le fichier texte dans lequel on veut ecrire
  12. Set Ftxt1 =  FSO1.createTextFile("C:\Documents and Settings\2.txt",true) 'true=ecrase
  13. MaVariable2="a"
  14. t=""
  15. 'on parcours chaque ligne du fichier texte
  16. Do While Not Ftxt.AtEndOfStream
  17.       MaVariable = Ftxt.Readline
  18.      
  19.       if (MaVariable2 = mid(MaVariable,19,18)) then
  20.      
  21.       '....... <- votre code ici pour traiter chaque ligne
  22.       'On ecrit ce que l'on veut dans le fichier
  23.        'Ftxt1.writeline (left(MaVariable,18)+left(MaVariable,18)+mid(MaVariable,50,13)+mid(MaVariable,63,5))
  24.       champ=trim(left(MaVariable,18))
  25.       types=trim(mid(MaVariable,50,13))
  26.       taille=trim(mid(MaVariable,63,5))
  27.       t= t +champ+" "+types+"("+taille+" ), "
  28.       MaVariable2= mid(MaVariable,19,18)
  29.       bool="true"
  30.    
  31. else
  32.    
  33.       nomtable=trim(mid(MaVariable,19,18))
  34.       champ=trim(left(MaVariable,18))
  35.       types=trim(mid(MaVariable,50,13))
  36.       taille=trim(mid(MaVariable,63,5))
  37.       t= t +champ+" "+types+"("+taille+" ), "
  38.       MaVariable2= mid(MaVariable,19,18)
  39.       end if
  40.       'MaVariable2= mid(MaVariable,19,18)
  41.    
  42. Loop
  43. t1=left(t,len(t)-2)
  44. Ftxt.Close
  45. Ftxt1.writeline ("create table "+nomtable+"("+t1+" )" )
  46. Ftxt1.Close


 
Le probleme est qu'en resultat, j'ai cela
 
create table2 (champ1 type(taille),champ2 type(taille),champ1 type(taille),champ2 type(taille))
 
il ne me met pas les nom de table à la suite en faite il les ecrase et accumule tout les champs des tables.
Comment pourrai je eviter cela
 
Merci

mood
Publicité
Posté le 16-08-2006 à 15:44:33  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  probleme script vbs

 

Sujets relatifs
Problème UTF8 +scriptPetit problème avec un script qui test la date d'installation de windo
problème avec un scriptProblème avec le script prog SquirrelMail...
Problème d'un script d'up d'image en ayant changé d'hébergement[Problème] Javascript et script SH
Problème d'encoding : erreur de script IE[SCRIPT WMI] Problème de permission avec Windows 98
[Resolu] probleme sur un scriptProbleme script Upload [résolu]
Plus de sujets relatifs à : probleme script vbs


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR