Solved

Comma delimited files to Paradox

Posted on 1997-11-02
3
389 Views
Last Modified: 2012-05-04
How do I import a comma delimited ascii file with variable field lengths to Paradox?
0
Comment
Question by:rainbowsoftware
3 Comments
 
LVL 2

Expert Comment

by:Waldek
Comment Utility
if not in code you may improt data to Excel and save as Paradox table
0
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 50 total points
Comment Utility
Rainbow,

If you have access to Microsoft Access (pun intended) then you can simply "attach" or "link" to the Paradox table then import the .CSV data straight into the table.

Good luck with your project!
Pegasus
0
 

Author Comment

by:rainbowsoftware
Comment Utility
What I really want is to make a Delphi application to handle all the
job from ASCII to PARADOX.
I have found a Freeware Component somewhere. It's a Table component
and handles comma delimited files, and it works fine in design time, but
running the program I get an error box telleing that the database canneot be accessed.
If someone could figure out why, I would appreciate it very much.
Here is the PAS-file:

unit Cdbascii;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, DbiErrs, DbiTypes, DbiProcs, DB, DBTables;

type
  TAsciiDelimTable = class(TTable)
  private
    { Private declarations }
    fQuote :Char;
    fDelim :Char;
  protected
    { Protected declarations }
    function CreateHandle: HDBICur; override;
    Procedure SetQuote(newValue :Char);
    Procedure SetDelim(newValue :Char);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    { These properties shouldn't be published anymore }
    property IndexFieldNames;
    property IndexName;
    property MasterFields;
    property MasterSource;
    property UpdateMode;
  published
    { Published declarations }
    Property Quote:Char Read fQuote Write setQuote Default '"';
    Property Delim:Char Read fDelim Write setDelim Default ',';
  end;

procedure Register;

implementation

uses DBConsts;

procedure Register;
begin
  RegisterComponents('Data Access', [TAsciiDelimTable]);
end;

constructor TAsciiDelimTable.Create(AOwner: TComponent);
Begin
  Inherited Create(AOwner);
  Exclusive:=True;
  TableType:=ttASCII;
  fQuote := '"';
  fDelim := ',';
End;

destructor TAsciiDelimTable.Destroy;
Begin
  Inherited Destroy;
End;

{ Utility routines }

function CheckOpen(Status: DBIResult): Boolean;
begin
  case Status of
    DBIERR_NONE:
      Result := True;
    DBIERR_NOTSUFFTABLERIGHTS:
      begin
        if not Session.GetPassword then DbiError(Status);
        Result := False;
      end;
  else
    DbiError(Status);
  end;
end;

function TAsciiDelimTable.CreateHandle: HDBICur;
const
  OpenModes: array[Boolean] of DbiOpenMode = (dbiReadWrite, dbiReadOnly);
  ShareModes: array[Boolean] of DbiShareMode = (dbiOpenShared, dbiOpenExcl);
var
  STableName: array[0..SizeOf(TFileName) - 1] of Char;
  SDriverType: array[0..12] of Char;
begin
  if TableName = '' then DBError(SNoTableName);
  AnsiToNative(DBLocale, TableName, STableName, SizeOf(STableName) - 1);
  StrPCopy(SDriverType, 'ASCIIDRV-'+Quote+'-'+Delim);
  Result := nil;
  while not CheckOpen(DbiOpenTable(DBHandle, STableName, SDriverType,
    nil, nil, 0, OpenModes[ReadOnly], ShareModes[Exclusive],
    xltField, False, nil, Result)) do {Retry};
end;

Procedure TAsciiDelimTable.SetQuote(newValue :Char);
Begin
 If Active Then
 {    DBError(SInvalidBatchMove); };
 fQuote := newValue;
End;
Procedure TAsciiDelimTable.SetDelim(newValue :Char);
Begin
 If Active Then
    {    DBError(SInvalidBatchMove); };
 fDelim := newValue;
End;

end.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now