Console app to write to MS Access database
- From: "mac" <mac32bit@xxxxxxxxxxx>
- Date: 19 Feb 2006 03:05:09 -0800
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.
.
- Prev by Date: Re: Master-Detail with ADODataSet
- Next by Date: Console app to write to MS Access database
- Previous by thread: Master-Detail with ADODataSet
- Next by thread: Console app to write to MS Access database
- Index(es):
Relevant Pages
|