?
Solved

D6+IB6

Posted on 2003-03-05
12
Medium Priority
?
1,347 Views
Last Modified: 2013-12-09
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
Comment
Question by:kacor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 6

Expert Comment

by:BAlexandrov
ID: 8074822
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
 
LVL 1

Expert Comment

by:vogonPoet
ID: 8075980


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
 
LVL 10

Author Comment

by:kacor
ID: 8086583
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
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 6

Expert Comment

by:BAlexandrov
ID: 8086676
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
 
LVL 6

Expert Comment

by:BAlexandrov
ID: 8086678
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
 
LVL 6

Accepted Solution

by:
BAlexandrov earned 400 total points
ID: 8086684
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
 
LVL 10

Author Comment

by:kacor
ID: 8086926
I have forgot the following is line 32
   DataModule1.IBSQL1.Open;

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

Janos
0
 
LVL 10

Author Comment

by:kacor
ID: 8086973
I have forgot the following is line 32
   DataModule1.IBSQL1.Open;

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

Janos
0
 
LVL 10

Author Comment

by:kacor
ID: 8086981
Thanks, this was the really help!!

I hope you will understand spasibo

Janos
0
 
LVL 10

Author Comment

by:kacor
ID: 8087274
Hi BAlexandrov,

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

Janos
0
 
LVL 6

Expert Comment

by:BAlexandrov
ID: 8087357
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
 
LVL 10

Author Comment

by:kacor
ID: 8090330
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question