• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1378
  • Last Modified:

D6+IB6

Hi Experts,

to get started with InterBase I made a simple IB application. The used IB database is supllied with IB: C:\Program Files\Common Files\Borland Shared\Data\EMPLOYEE.GDB. On the Main form is a lonly Combobox1 and when the form will be created the combobox gets the items DEPT_NO (first field) from the Department table. IBTransaction1 and IBSQL1 are connected to IBDatabase1, and it's SQL statement is as follows:

select DEPT_NO  from DEPARTMENT
order by DEPARTMENT

Main form
=========
type
   TfrmMain = class(TForm)
    ComboBox1: TComboBox;
    procedure LoadComboItems();
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

uses DataModule;

{$R *.dfm}

procedure TfrmMain.LoadComboItems();
begin
   DataModule1.IBTransaction1.StartTransaction;
   DataModule1.IBSQL1.ExecQuery;
   while not Eof do
   begin
      ComboBox1.Items.Add(DataModule1.IBSQL1.Fields[0].Value);
      Next;
   end;

end;


procedure TfrmMain.FormCreate(Sender: TObject);
begin
   LoadComboItems;
end;



On the DataModule they are the following components:
=========================================
type
  TDataModule1 = class(TDataModule)
    IBDatabase1: TIBDatabase;
    IBTransaction1: TIBTransaction;
    IBSQL1: TIBSQL;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  DataModule1: TDataModule1;

First the DataModule will be created because I changed the creation order.
The project file
===========
  Application.Initialize;
  Application.CreateForm(TDataModule1, DataModule1);
  Application.CreateForm(TfrmMain, frmMain);
  Application.Run;

After running I get an error message:

---------------------------
Debugger Exception Notification
---------------------------
Project IB_SQL2.exe raised exception class EIBClientError with message 'Operation cancelled at user's request'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

Of course I made no break.

Please your help

with best regards

Janos
========================================
Support bacterias
this is the only culture some people have
0
kacor
Asked:
kacor
  • 6
  • 5
1 Solution
 
BAlexandrovCommented:
Set the database to not ask for login, or include in uses clause login_dialog or something.... realy can't remember now.
If you have not set user name and password as parameters in database component it tries to show login dialog but if it is not in your uses clause - it shows that missleading error.
Double click database and set the parameters -
sysdba
masterkey
are the default
0
 
vogonPoetCommented:


I'm not using D6 and related components, but I would expect the LoadComboBox to look something more like this:


begin
  DataModule1.IBTransaction1.StartTransaction;
  DataModule1.IBSQL1.open;
 
  while not DataModule1.IBSQL1.Eof do
  begin
     ComboBox1.Items.Add(DataModule1.IBSQL1.Fields[0].Value);
     DataModule1.IBSQL1.Next;
  end;
  DataModule1.IBSQL1.close;

end;


NOT COMPILED... USE SOMEONE ELSE'S OWN RISK..  :)
0
 
kacorretiredAuthor Commented:
Hi BAlexandrov and vogonPoet,

yesterday I've tested the proposition and my newer ideas.

BAlexandrov, thanks, you have right, the first to do is to set the database parameters in the dataset editor, and I made so.

vogonPoet, thanks, I made the proposed settings, and i got an error message as follows:

[Error] Main.pas(32): Statement expected, but expression of type 'Boolean' found

I don't understand. Of course if you have some new ideas I am ready to test it.

thanks again

Janos
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
BAlexandrovCommented:
Short Answer:  DataModule1.IBSQL1.open returns true/false for if the sql is open.
Correct one is DataModule1.IBSQL1.ExecSQL

See the followed long answer
0
 
BAlexandrovCommented:
procedure TfrmMain.LoadComboItems;
begin
 DataModule1.IBTransaction1.StartTransaction;
 DataModule1.IBSQL1.ExecQuery;
 
 while not DataModule1.IBSQL1.Eof do
 begin
    ComboBox1.Items.Add(DataModule1.IBSQL1.Fields[0].Value);
    DataModule1.IBSQL1.Next;
 end;
 DataModule1.IBSQL1.close;
 DataModule1.IBTransaction1.Commit;

 ComboBox1.ItemIndex:=0;
end;
0
 
BAlexandrovCommented:
The data module. See transaction and database params!



object DataModule1: TDataModule1
  OldCreateOrder = False
  Left = 249
  Top = 106
  Height = 480
  Width = 696
  object IBDatabase1: TIBDatabase
    Connected = True
    DatabaseName = 'localhost:C:\Program Files\FireBird\examples\EMPLOYEE.GDB'
    Params.Strings = (
      'user_name=sysdba'
      'password=masterkey')
    LoginPrompt = False
    DefaultTransaction = IBTransaction1
    IdleTimer = 0
    SQLDialect = 1
    TraceFlags = []
    Left = 28
    Top = 14
  end
  object IBTransaction1: TIBTransaction
    Active = False
    Params.Strings = (
      'read_committed'
      'rec_version'
      'nowait')
    AutoStopAction = saNone
    Left = 106
    Top = 16
  end
  object IBSQL1: TIBSQL
    Database = IBDatabase1
    ParamCheck = True
    SQL.Strings = (
      'select DEPT_NO  from DEPARTMENT'
      'order by DEPARTMENT')
    Transaction = IBTransaction1
    Left = 190
    Top = 20
  end
end
0
 
kacorretiredAuthor Commented:
I have forgot the following is line 32
   DataModule1.IBSQL1.Open;

Now I'll read the new infos :-))

Janos
0
 
kacorretiredAuthor Commented:
I have forgot the following is line 32
   DataModule1.IBSQL1.Open;

Now I'll read the new infos :-))

Janos
0
 
kacorretiredAuthor Commented:
Thanks, this was the really help!!

I hope you will understand spasibo

Janos
0
 
kacorretiredAuthor Commented:
Hi BAlexandrov,

I tried to use FieldByName instead of Field, but I got an error message. Do you know this phenomena?

Janos
0
 
BAlexandrovCommented:
I am Bulgarian but know russian also ;)

IBSQL is not an dataset so do not expect it to have standart methods.

IBQuery is.

For IBSQL there is such funtionality -  IBSQL1.current.byName....

Find on Internet - there are many examples.
See
ibase.ru
http://www.volny.cz/iprenosil/interbase/index.htm
and the whole IB wbe site ring
0
 
kacorretiredAuthor Commented:
Hi BAlexandrov and vogonPoet,

yesterday I've tested the proposition and my newer ideas.

BAlexandrov, thanks, you have right, the first to do is to set the database parameters in the dataset editor, and I made so.

vogonPoet, thanks, I made the proposed settings, and i got an error message as follows:

[Error] Main.pas(32): Statement expected, but expression of type 'Boolean' found

I don't understand. Of course if you have some new ideas I am ready to test it.

thanks again

Janos
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now