help reqd writing file io for db

help reqd writing file io for db

Post by Adam Kalajzi » Sun, 03 Nov 1996 04:00:00



I am trying to write a db prog and need help writing a io file that handels
the records. the listing is as follows please help by emailing me at

the code:

{
 This file is the character file i/o
written by adam Kalajzich sunday 13/10/1996.

Quote:}

unit Charfile;

interface

uses
        sysutils;

type
        {record of characters}
        CharacterRecord = RECORD
                Diffret types of data goes here.
        end;

CharFileType = File of CharacterRecord;

const
        CharSize = SizeOf(CharacterRecord);

procedure OpenCharFile (var f : CharFileType; Const CharFileName : String);
procedure CloseCharFile (var f : CharFileType);
procedure Lookup (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);
procedure Update (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);
procedure Add (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);

implementation

procedure OpenCharFile (var f : CharFileType; Const CharFileName : String);
begin
        if FileExists(CharFileName) then
        begin
                Assign(f, CharFileName);
                ReSet(f);
        end

        else
        begin
                Assign(f, CharFileName);
                ReWrite(f);
        end;

end;

procedure CloseCharFile (var f : CharFileType);
begin
        Close (f);
end;

procedure Lookup (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);
var
        RecordNo : Integer;
begin
        RecordNo := Index * CharSize;
        Seek(f, RecordNo);
        Read(f, Rec);
end;

procedure Update (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);
var
        RecordNo : Integer;
begin
        RecordNo := Index * CharSize;
        Seek(f, RecordNo);
        Write(f, Rec);
end;

procedure Add (var f : CharFileType; Index : Integer; var Rec : CharacterRecord);
var
        Size : Longint;
begin
        size := filesize(f);
        Seek(f, size);
        Write(f, Rec);
end;

end.

Adam Kalajzich

http://www.mpx.com.au/~lindamus

"life is pain, lady. Anyone that tells you diffrently is tyring to sell you something."
- Dread Pirate Roberts.

 
 
 

1. Reqd help for reading flat text file throgh OLE DB

Reqd help for reading flat text  file throgh OLE DB

Dear Sir,

    I am facing problem in reading flat text file throgh SQL 7 query analyser.
    My query is as follows

select * from openrowset('DTSFlatFile'
, 'Data Source=\\myserver\bosac7\t2.txt
;Mode=Read;Row Delimiter={LF};File Format=0;Column Delimiter=|
;File Type=1;Skip Rows=0;First Row Column Name=False
;Number of Column=0;Max characters per delimited column=255'
,'SELECT * ')

    error given is

Server: Msg 7303, Level 16, State 2, Line 1
Could not initialize data source object of OLE DB provider 'DTSFlatFile'.
[OLE/DB provider returned message: Error opening datafile: The system cannot find
the file specified.]

content of text file T2 is

ACC | S R Investment | 500.00
REL | L R Trades | 300.00

Please note that T2.TXT file existing in the same folder as specified in data
source statement and
despite correct path it is giving error.

can u please give solution to the above problem

Thanks

Bharat Sangani

2. Problem Backing Up/COPYing Database

3. help reqd. with text file

4. Accessing Access database via Internet

5. help on Java db & IO

6. ADO/VB cannot detect errors raised from stored procedure of SQL 7

7. Help with reporting file IO activity for each tablesapce

8. SQL 7.0, MMC and Windows 2000 RC1

9. Open text file, read line, write to DB, read next line, write to Db and so on...HELP

10. MultiDimensional DB:- Info Reqd

11. Internet enabled db reqd.