Solved

Comma delimited files to Paradox

Posted on 1997-11-02
3
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:Waldek
ID: 1349351
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
ID: 1349352
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
ID: 1349353
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Suggested Courses
Course of the Month4 days, 23 hours left to enroll

635 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