Tuesday, December 21, 2004

Console application with ADO in Delphi

I am working on this project which need little plug-in to be written. Main thing is that the plugin should be console application and must have database access support. So, I started writing a code in Delphi but couldn't get things work properly. No matter what I tried, I got memory access violation. With little research, I found that CoInitialization is needed to be called before any ADO component is initialized and used. Below is the source of sample console application with ADO support in Delphi;
program Project1;
{$APPTYPE CONSOLE}

uses
 ADOdb,
 ActiveX;

var
 conMain : TADOConnection;
 tab1 : TADOTable;

begin
 CoInitialize(nil);
 conMain := TADOConnection.Create(nil);
 tab1 := TADOTable.Create(nil);

 conMain.ConnectionString := '{your connection string here}';
 conMain.LoginPrompt := False;
 conMain.Open;

 tab1.Connection := conMain;
 tab1.TableName := '{your table name here}';
 tab1.Active := True;
 tab1.Recordset.MoveFirst;

while not tab1.Recordset.EOF do begin writeln(tab1.Recordset.Fields[1].Value); tab1.Recordset.MoveNext; end;

CoUninitialize; end.

Monday, December 13, 2004

My first PHP application

Since I am a delphi lover, I haven't got chance to develop serious application in it. Instead, I had to learn new things. First of all, we had this project in C#. Now, I had to work on PHP. But, the PHP project was really interesting. The main objective of this project was to parse various XML files and update MySQL database. Also, to develop web front end to implement search function. This project was actually a part of www.shoes--boots.com site.