Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Comma delimited files to Paradox

Posted on 1997-11-02
3
Medium Priority
?
410 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
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 100 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

Technology Partners: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Loops Section Overview

926 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