But an error in the Delphi
CodePudding user response:
You have to clarify your running environment, good to give adviceThe DELPHI runtime environment, use the controls
To the database version? MSSQL2K, 2 k5, 2 k8?
CodePudding user response:
Still have a plenty of error? What did the mistake? Screenshots or text descriptionsCodePudding user response:
Procedure TForm_ChangCSVToDBFF. N1Click (Sender: TObject);
Var
Llist, BBList: TStringList;
I, j: Integer;
Fname, Path: string;
The begin
Self. OpenDialog1. Title:='open the CSV file;
Self. OpenDialog1. FileName:='*. CSV';
Self. OpenDialog1. Filter:='CSV file (*. CSV) | *. CSV | all files (*. *) | *. *';
If Self. OpenDialog1. Execute then
The begin
The Self. The StatusBar1. Panels [1]. The Text:=Self. OpenDialog1. The FileName;
Self. SaveDialog1. Title:='save DBF for... ';
Self. SaveDialog1. DefaultExt:='DBF';
Self. SaveDialog1. Filter:='dDBASE files (*. DBF) | *. DBF | all files (*. *) | *. *';
Fname:=ExtractFileName (Self) OpenDialog1) FileName);
Fname:=ChangeFileExt (Fname, ");
Self. SaveDialog1. FileName: Fname +='. DBF ';
If Self. SaveDialog1. Execute then
The begin
Fname:=ExtractFileName (Self) SaveDialog1) FileName);
Path:=ExtractFilePath (Self) SaveDialog1) FileName);
Llist:=TStringList. Create;
Llist. LoadFromFile (Self) OpenDialog1) FileName);
BBList:=TStringList. Create;
BBList. Delimiter:=', ';
Self. Table1. The Active:=False;
Self. Table1. DisableControls;
Self. Table1. DatabaseName:=Path;
Self. Table1. TableName:=Fname;
Self. Table1. TableType:=ttDbase;
Self. Table1. FieldDefs. The Clear;
Self. Table1. IndexDefs. The Clear;
BBList. DelimitedText:=llist. Strings [0];
Self. Table1. FieldDefs. Add (BBList [0], ftInteger, 0, True);
For I:=1 to BBList. Do the Count - 1
The begin
Self. Table1. FieldDefs. Add (BBList [I], ftFloat, 0, True);
end;
Self. Table1. CreateTable;
Self. Table1. The Active:=True;
Self. ProgressBar1. Min:=0;
Self. ProgressBar1. Max:=llist. Count - 1;
For I:=1 to llist. Do the Count - 1
The begin
Self. Table1. Append;
BBList. DelimitedText:=llist. Strings [I];
Self. Table1. Fields [0]. AsInteger:=StrToInt (BBList [0]).
For j:=1 to BBList. Do the Count - 1
The begin
If BBList [j] <> "' then
The begin
Self. Table1. Fields [j] AsFloat:=StrToFloat (BBList [j]);
End the else
The begin
Self. Table1. Fields [j]. Value:=9999;
end;
end;
Self. Table1. Post;
Self. ProgressBar1. Position:=I;
end;
Self. Table1. EnableControls;
Self. ProgressBar1. Position:=0;
Llist. Free;
BBList. Free;
end;
end;
end;