Console app to write to MS Access database



Hi all

I am fairly new to Delphi so could someone look at this code for me and
tell me if it is any good. It works but I am not sure if it is the
right way to do it. It is a simple console app that writes to an Access
database.

I had to add "ActiveX" of all things to "Uses" to get
CoInitialize/CoUninitialize to work is that the right one?

Thanks in advance!



program Project1;

{$APPTYPE CONSOLE}

uses
ADODB, ActiveX;


Var
ADOTable1: TADOTable;
begin

{ TODO -oUser -cConsole Main : Insert code here }

Writeln('Opening database...');

CoInitialize(nil);
try
ADOTable1 := TADOTable.Create(nil);
ADOTable1.ConnectionString :=
'Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\Databases\Frecords.mdb;Persist Security Info=False' ;
ADOTable1.Name := 'ADOTable1';
ADOTable1.TableName := 'Table1';
ADOTable1.Open;

{ do some stuff }
ADOTable1.Append;
ADOTable1.FieldByName('FileName').AsString := 'Hello World';
ADOTable1.Post;
ADOTable1.Close;
ADOTable1.Free;
finally
CoUninitialize();
end;

Writeln('Done!');
end.

.



Relevant Pages

  • Re: Communication between Borland Pascal DOS program and Delphi
    ... Delphi Professional 5. ... The Delphi program is waiting for an event from ... > able to receive a message/signal from a Borland Pascal DOS application? ... If much information is sent by the console app, a pipe may be a better solution, but this requires more changes to both applications. ...
    (comp.lang.pascal.delphi.misc)
  • Re: C# to HTML convertor
    ... and syntax highlighting can be specified in the ... Would be nice to add HTML, PHP, SQL, Delphi, etc.;) ... >> in the output HTML, ... >I just need to turn it into a console app to process the files from a build ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Performance Analysis Tools
    ... tbone wrote: ... I'm working on a Delphi 4 console app and have been asked to improve ... its UDP message throughput. ...
    (borland.public.delphi.non-technical)
  • Re: Performance Analysis Tools
    ... I'm working on a Delphi 4 console app and have been asked to improve ... its UDP message throughput. ... Australian Bridal Accessories:= http://www.bridalbuzz.com.au ...
    (borland.public.delphi.non-technical)
  • Re: Communication between Borland Pascal DOS program and Delphi
    ... concurrently is a Windows application (not a console app) written with ... Delphi Professional 5. ... A BP program can start any 32 bit windows program simply with exec ... achieved, a FAQ citation should be in order, in both FAQs. ...
    (comp.lang.pascal.borland)