Bonjour à tous,
j'importe un fichier CSV dans une table Access de cette manière :
Mon fichier CSV est parfait mais lorsque je vais voir dans ma table, une colonne me pose problème. Il ne s'agit pourtant que de texte comme d'autre colonnes.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 procedure TfrmMain.ImportDirectCVSToBase(PathFichierCSV, NomFichierCSV:TFileName); const Requete='INSERT INTO [%s] IN "%s" SELECT * FROM %s'; begin try //Gestion du délimiteur ';' CreerSchemaIni(PathFichierCSV, NomFichierCSV,';'); ADOConnection1.Close; ADOConnection1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+PathFichierCSV+';Extended Properties="text;HDR=YES;Format=Delimited"'; ADOConnection1.Execute(Format(Requete,['Q_Zmir0678',DBPath,NomFichierCSV])); Except on E:Exception do begin showmessage(E.Message); end; end; end;
Explications :
Dans Access j'ai un champ 'stor' ==> champ texte 50
Dans mon fichier CSV les valeurs correspondants à 'stor' ressemble à : F300 ou P563, etc ...
Mais dans ma table après l'importation il ne m'a importé que 300 ou 563 !!
bizarre non ?
Partager