Autor Beitrag
flankengott
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: So 28.09.08 11:10 
Hallo!

Ich möchte mir ein Programm schreiben, welches mir ermöglicht csv files (mit ";") in eine Access - DB zu importieren.
Nun weis ich nicht ganz genau wie ich das machen soll.

Vielleicht könnte Ihr mir ja ein paar Tipps geben!

Lg
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 28.09.08 11:46 
Na, einfach die CSV-Daten einlesen und dabei in eine Access-Tabelle blasen.

Einen CSV-Reader gibt es hier:
www.delphipraxis.net...highlight=tcsvreader

Folgenden Code kannst Du verwenden, wenn die Access-Tabelle in Spaltenanzahl und Datentyp genauso wie die CSV-Datei aussieht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
Var
  csvReader : TCSVReader;
  sData : TFileStream;

Begin
  sData := TFileStream.Create('Sample.CSV',fmOpenRead);
  csvReader := TCSVReader.Create (sData, ';');
  Try
    While not csvReader.Eof Do Begin
      MyAccessTable.Append;
      For i:=0 to csvReader.ColumnCount - 1 Do                                 
        MyAccessTable.Fields[i].Value := csvReader.Columns[i]; 
      MyAccessTable.Post;
      csvReader.Next;                                                         
    End;     
  Finally
    csvReader.Free;
    sData.Free;
  End;
End;

_________________
Na denn, dann. Bis dann, denn.
flankengott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: So 28.09.08 12:03 
erstmals danke!

soll ich jetzt noch zbsp. einen button auf die form ziehen und diese source dann reinschreiben und nebenbei einen opendialog raufziehen zum öffnen des files?
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 28.09.08 14:23 
Das wäre doch mal ein Anfang. Die Access-DB und die Tabelle existieren schon?

_________________
Na denn, dann. Bis dann, denn.
flankengott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: So 28.09.08 15:05 
die access db ist schon fertig...
stehen auch schon einträge drinnen!