Recent

Author Topic: IBExpress - best practise to change to "active"?  (Read 804 times)

Nicole

  • Sr. Member
  • ****
  • Posts: 355
IBExpress - best practise to change to "active"?
« on: August 16, 2022, 09:11:09 pm »
I am new to IBExpress and portate old cold into it (coming from FireDAC, which did some tricks automatically).
So I am not sure about the basics of IBExpress.

This I have at the moment and it works at design-time:
ibdatbase
ibconnection
tbtransaction
ibdatasource
ibdataset

=> DBGrid

Above this DBGrid are Buttons, which generate SQL select-Codes for my database.
Their results I want to see at runtime.

What I want to do at the shortest way:
1) change the SQL code
2) display the updated DBGrid

my questions
a) Where is the best place to change the SQL-request?
b) What has to be set to "active" or "connect" either for the first request or for an update of the SQL?
c) How can I avoid, that the password is requested every time?

Thanks.

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: IBExpress - best practise to change to "active"?
« Reply #1 on: August 17, 2022, 01:00:33 am »
I am new to IBExpress and portate old cold into it (coming from FireDAC, which did some tricks automatically).
So I am not sure about the basics of IBExpress.

This I have at the moment and it works at design-time:
ibdatbase
ibconnection
tbtransaction
ibdatasource
ibdataset

=> DBGrid

Above this DBGrid are Buttons, which generate SQL select-Codes for my database.
Their results I want to see at runtime.

What I want to do at the shortest way:
1) change the SQL code
2) display the updated DBGrid

my questions
a) Where is the best place to change the SQL-request?
The dataset is the only place where you can change the sql.
b) What has to be set to "active" or "connect" either for the first request or for an update of the SQL?
You set the datasets active := false change the sql and then set it to true again.
c) How can I avoid, that the password is requested every time?
on ibdatabase there is a property named loginPrompt set it to false.

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #2 on: August 17, 2022, 09:49:27 am »
Thank you for your answer.
Unfortunately it does not work for me.

At design-time the dataset asks for the keyword on setting it to active.
After I key it in another time, it works fine.

At runtime, I do not see this login-request, but the error message:

[Window Title]
Fehler

[Content]
Projekt project_Tiger hat Exception-Klasse »External: ACCESS VIOLATION« ausgelöst mit der Meldung:
Access violation reading from address $00000000000000C0.

 In Datei 'frame_waren_.pas' in Zeile 37:
DataModule1.IBDataSet_Waren.Active:=true;

[Ok]

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: IBExpress - best practise to change to "active"?
« Reply #3 on: August 17, 2022, 10:04:15 am »
Thank you for your answer.
Unfortunately it does not work for me.

At design-time the dataset asks for the keyword on setting it to active.
After I key it in another time, it works fine.

At runtime, I do not see this login-request, but the error message:

[Window Title]
Fehler

[Content]
Projekt project_Tiger hat Exception-Klasse »External: ACCESS VIOLATION« ausgelöst mit der Meldung:
Access violation reading from address $00000000000000C0.

 In Datei 'frame_waren_.pas' in Zeile 37:
DataModule1.IBDataSet_Waren.Active:=true;

[Ok]
attach a sample application that  demonstrates the problem to take a closer look.

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #4 on: August 17, 2022, 10:09:46 am »
How shall this work?
The environment of the db is in a VM of more than 100 GB and the data inside are confidential.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4573
  • Compiler Developer
Re: IBExpress - best practise to change to "active"?
« Reply #5 on: August 17, 2022, 01:37:02 pm »
How shall this work?
The environment of the db is in a VM of more than 100 GB and the data inside are confidential.

You simply need to try to provide a small, self contained example that shows the same behaviour. Without such it's nearly always hard to tell what goes wrong, because some small setting might be different that you didn't mention or didn't even notice.

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #6 on: August 17, 2022, 01:42:00 pm »
Again:
How shall this work? - You need a driver for a Firebird db and this driver is installed in the operating system of my Virtual machine.

rvk

  • Hero Member
  • *****
  • Posts: 4949
Re: IBExpress - best practise to change to "active"?
« Reply #7 on: August 17, 2022, 01:42:34 pm »
In Datei 'frame_waren_.pas' in Zeile 37:
DataModule1.IBDataSet_Waren.Active:=true;
Look at the order the forms are created (in project options>forms).

The form with this code (probably in formcreate) is in front of the DataModule1.
You need to move DataModule1 to the top so it's created first.

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #8 on: August 17, 2022, 01:54:32 pm »
Thank you for the reply. I checked it, the series is
- dbmodul
- form1
- frame1 => for the db which does not work

rvk

  • Hero Member
  • *****
  • Posts: 4949
Re: IBExpress - best practise to change to "active"?
« Reply #9 on: August 17, 2022, 02:06:47 pm »
Thank you for the reply. I checked it, the series is
- dbmodul
- form1
- frame1 => for the db which does not work
And how is frame1 created?
Where is it used?

What function is line 37 of In Datei frame_waren_.pas and where is this function called?

And is there a special reason for using a frame? Are you reusing that frame somewhere else too?

rvk

  • Hero Member
  • *****
  • Posts: 4949
Re: IBExpress - best practise to change to "active"?
« Reply #10 on: August 17, 2022, 02:10:29 pm »
BTW. If frame1 is really a frame then it shouldn't be in the auto-create section of Forms in Project options.

A Frame isn't a Form which is to be autocreated. It is to be used by a component TFrame.

So, is that really a frame of just a poor named Form?

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #11 on: August 17, 2022, 03:57:44 pm »
This hint with the frames was a clou!
These frames are created at runtime and I checked the wrong list in my project inspector.
Your question made me aware of that.

This is corrected thing:
Now my DBModul is REALLY created at the first place and I am one error-message step further.
It reads:

Code: Text  [Select][+][-]
  1. [Debuggerausnahmen-Nachricht]
  2.  
  3.  
  4. [Break]
  5. Projekt project_Tiger hat Exception-Klasse »EIBInterBaseError« ausgelöst mit der Meldung:
  6. Engine Code: 335544472
  7. Your user name and password are not defined. Ask your database administrator to set up a Firebird login
  8.  
  9.  In Datei 'IBDatabase.pas' in Zeile 1082
  10.  
  11.  
  12. [Diesen Ausnahmetyp übergehen]
  13.  
  14. [Continue]

Which means to me in other words:
"Key in user name and password somewhere."
But where exactly? (pls see the list of what I have in my first posting)

rvk

  • Hero Member
  • *****
  • Posts: 4949
Re: IBExpress - best practise to change to "active"?
« Reply #12 on: August 17, 2022, 04:13:27 pm »
Usually for TIBDatabase you set LoginPrompt to false (so it doesn't prompt you with a login dialog each time).
But in that case you also need to provide the login details in code.

You can add this to your IBDataSet_Waren.Params property
Code: [Select]
user_name=SYSDBA
password=masterkey

Or you can do it in code in the FormCreate or DataModuleCreate
Code: Pascal  [Select][+][-]
  1. IBDataSet_Waren.Params.Values['user_name'] := Username_read_from_config_file;
  2. IBDataSet_Waren.Params.Values['password'] := Password_read_from_config_file;

The first one is the easiest but then the username and password would always need to be the same.

Nicole

  • Sr. Member
  • ****
  • Posts: 355
Re: IBExpress - best practise to change to "active"?
« Reply #13 on: August 17, 2022, 06:19:40 pm »
This looks good, but it does not work yet.

I found in dataset a
database.params.strings

There was already a line
user_name=SYSDBA


I added
password=masterkey

Never the less at design-time I am asked to key in the pw, if I check "active".
If I do, the thing works.
At runtime there is an error-message instead of a request.

So either the password is on the wrong place or it is not found at all.

rvk

  • Hero Member
  • *****
  • Posts: 4949
Re: IBExpress - best practise to change to "active"?
« Reply #14 on: August 17, 2022, 06:34:48 pm »
Don't forget to set the LoginPromot to false.

Also, don't leave the TIBDatabase connected at design time.
Always set active to false before running your program.
Otherwise you can't set anything before the connection is made.

It's best to set the TIBDatabase to active in your code.
(So you can set the filelocation to some alternative before the connection is made)

 

TinyPortal © 2005-2018