Struggling to connect Lazarus to database

Mike7

Expert Member
Joined
Nov 3, 2011
Messages
2,955
Reaction score
3,045
Does anyone here have any knowledge of lazarus/delphi?

I'm extremely frustrated as I can't seem to get such a simple thing to work.

I've created a database in IBConsole which I've saved but every time I try and connect from lazarus it says it's not a valid database? I've googled but I can't find any solution.

IBConsole seems to save the database as .IB which according to the instructions I'm following is correct. When in Lazarus after creating the IBconnection component and searching for my database in the Object inspector view it says its not a valid database?

This seems stupid but I can't get it working...halp!!!!
 
Assume server is on your PC and firewall is not blocking it. not a valid database could mean that the path is incorrect.
the path must be the local path on the server. cannot use mapped drive.

Many moons since I used Delphi. But this comes from a project. I have a TDatabase component in a datamodule that provides the interface to my db. If you look at the .DFM file (in text form) this is what you see

object bxIBDatabase: TbxIBDatabase
OldCreateOrder = True
object dbDatabase: TDatabase
DatabaseName = 'IBREMOTE'
DriverName = 'INTRBASE'
LoginPrompt = False
SessionName = 'Default'
end
end

The DatabaseName is IBREMOTE what you will hook your conmponents to. You can make it whatever else


The Connect method is below
procedure TbxIBDatabase.SetConnected(AValue: boolean);
begin
if Connected = AValue then
Exit;

if AValue = False then
begin
dbDatabase.Connected := False;
Exit;
end;

if Trim(Database) = '' then
raise EbxIBDatabase.Create('Database property not set');

if Trim(Username) = '' then
raise EbxIBDatabase.Create('Username property not set');

if Trim(Password) = '' then
raise EbxIBDatabase.Create('Password property not set');

dbDatabase.Params.Clear;

dbDatabase.Params.Add('OPEN MODE=READ/WRITE');
dbDatabase.Params.Add('SCHEMA CACHE SIZE=8');
dbDatabase.Params.Add('SQLQRYMODE=SERVER');
dbDatabase.Params.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
dbDatabase.Params.Add('SCHEMA CACHE TIME=-1');
dbDatabase.Params.Add('DRIVER FLAGS=512');
dbDatabase.Params.Add('ENABLE SCHEMA CACHE=FALSE');
dbDatabase.Params.Add('SCHEMA CACHE DIR=');
dbDatabase.Params.Add('ENABLE BCD=FALSE');
dbDatabase.Params.Add('SERVER NAME=' + Database);
dbDatabase.Params.Add('USER NAME=' + Username);
dbDatabase.Params.Add('PASSWORD=' + Password);

dbDatabase.Connected := True;
end;


That is about as much as I can help you. It was tricky to figure out how to use the TDatabase component in the beginning. Usually you created an alias in the BDE Admin then hooked all components to this alias. But in a more dynamic environment you dont want to mess with BDE. So the TDatabase creates the alias (IBREMOTE in this case) and you hook all your db stuff to that. Then the TDatabase connects to the DB server.

But seriously why Delphi? Rather go C#.
 
Phew, haven't seen Delphi/Pascal code since forever ago!
 
Yeah glad l left it behind. I still have systems out in the field I developed 25 years ago. Replacing the last one now with current tech
 
You should maybe look at the new Delphi - the only multi-platform solution currently. Write once and deploy binaries to Win32, Win64, MacOS, IOS and Android.

Mike7 are you working in Delphi or Lazarus? And which database connection components are you using?
 
You should maybe look at the new Delphi - the only multi-platform solution currently. Write once and deploy binaries to Win32, Win64, MacOS, IOS and Android.

VS targets are is pretty multiplatform. All except MacOS. Not the IDE though. My biggest issue problem is that the Pascal language is terrible by today's standards. does not promote OO becuase of it's clumsy syntax.
 
Not really sure how you can say Pascal does not promote OO. That seems more of a personal opinion to me, than a fact.

My main beef with VS is the enormous supporting framework that has to ship with, and speed (or lack there of). It being a MS you can bet your bottom dollar it will work fantastically on MS product, but will suck on competing platforms.
 
single inheritance, interfaces, composition, polymorphism, abstraction, encapsulation. seems OO to me.
 
Not really sure how you can say Pascal does not promote OO. That seems more of a personal opinion to me, than a fact.

My main beef with VS is the enormous supporting framework that has to ship with, and speed (or lack there of). It being a MS you can bet your bottom dollar it will work fantastically on MS product, but will suck on competing platforms.

single inheritance, interfaces, composition, polymorphism, abstraction, encapsulation. seems OO to me.

Yes my opinion only. Yes Delphi does fully support OO. I don't dispute that part.

What I am saying is that I find Pascal syntax incredibly cumbersome. It is a dated language. I loved and used Delphi extensively since it was launched (>25 years) and wrote very large systems with it.
My pet frikken hates are:
- The whole interface/implementation sections is a mission. They have to exactly be in sync otherwise error. Right down to method argument name. Not just type, name as well. Non-sensical. So up and down the file all the time when you make changes. Yes there is a shortcut, but it's a major irritation
- Variable declarations only at the top of the method
- Class name prefix to every method
- Loads of clutter in a typical class implementation

The question is how many Delphi devs just slap functionality into a control's event handler. Prob most of them. I know I did way back. That's bad design. I doubt that there are many Delphi devs that stick to SOLID principles in a typical Delphi app. Would be too much effort.

Newer languages like Java/C# are much leaner in terms of syntax and clutter and removes a lot of the cognitive load when reading a source file.

When you talk about the 'enormous' framework with VS. Yes, but it is built into Win already. But then there is a lot of stuff provided that you just use. The pascal run time libs are more limited and you have roll your own lot of the time. I have deployed .NET apps on Linux devices running as embedded appliances, and yes not as fast as your PC, but the CPU is much slower than a PC.

These are just my rants and everybody has the right to differ from me. But for a noob, I will not recommend Delphi.

But we are hijacking this thread
 
Last edited:
agreed, the verbose syntax of delphi is a killer.

cut my teeth on delphi 15 years ago. kbmMW was fun :)
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X