Solved

Comma delimited files to Paradox

Posted on 1997-11-02
3
400 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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