Solved

TIBDatabase Create/Open Database - D7

Posted on 2006-10-19
11
2,720 Views
Last Modified: 2012-08-13
Hi Experts,

my form contains the following components:
    OpenDialog1: TOpenDialog;
    IBDatabase1: TIBDatabase;
    IBTransaction1: TIBTransaction;
    Button1: TButton;

By pressing Button1 I'd like to create a new database.

procedure TForm1.Button1Click(Sender: TObject);
begin
   if OpenDialog1.Execute then
      IBDatabase1.DatabaseName := OpenDialog1.FileName;
   IBDatabase1.Params.Clear;
   IBDatabase1.Params.Add ('user_name=sysdba');
   IBDatabase1.Params.Add ('password=masterkey');
   IBDatabase1.SQLDialect := 3;
   IBDatabase1.CreateDatabase;
end;

Running the project I got the error message:

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EIBInterBaseError with message 'Your user name and password are not defined. Ask your database administrator to set up an InterBase login'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------

In principle the SYSDBA and masterkey are preset.
What is wrong? How can I open the created DB?

wbr Janos
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
11 Comments
 
LVL 3

Expert Comment

by:cobi100
ID: 17774639
try it like this:

  if OpenDialog1.Execute then
      IBDatabase1.DatabaseName := OpenDialog1.FileName;
   IBDatabase1.Params.Clear;
   IBDatabase1.Params.Add ('USER ''SYSDBA''');
   IBDatabase1.Params.Add ('PASSWORD ''masterkey''');
   IBDatabase1.SQLDialect := 3;
   IBDatabase1.CreateDatabase;
0
 
LVL 10

Author Comment

by:kacor
ID: 17775702
thanks, the half of points is yours! Could you answer my second question too: how to open a DB?
0
 
LVL 3

Expert Comment

by:cobi100
ID: 17776449
didn't see that part of the question, try:

   IBDatabase1.Open;
0
Independent Software Vendors: 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!

 
LVL 10

Author Comment

by:kacor
ID: 17777003
I used the same procedure:

procedure TForm1.Button2Click(Sender: TObject);
begin
   if OpenDialog1.Execute then
      IBDatabase1.DatabaseName := OpenDialog1.FileName;
   IBDatabase1.Params.Clear;
   IBDatabase1.Params.Add ('USER ''SYSDBA''');
   IBDatabase1.Params.Add ('PASSWORD ''masterkey''');
   IBDatabase1.SQLDialect := 3;
   IBDatabase1.LoginPrompt := False;
   IBDatabase1.Open;
end;

and the error message is:

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EIBInterBaseError with message 'Your user name and password are not defined. Ask your database administrator to set up an InterBase login'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------
0
 
LVL 3

Expert Comment

by:cobi100
ID: 17777450
Actualy, just IBDatabase1.Open; will do

procedure TForm1.Button2Click(Sender: TObject);
begin
   IBDatabase1.Open;
end;

you have set all the parameters in this other method

procedure TForm1.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
      IBDatabase1.DatabaseName := OpenDialog1.FileName;
   IBDatabase1.Params.Clear;
   IBDatabase1.Params.Add ('USER ''SYSDBA''');
   IBDatabase1.Params.Add ('PASSWORD ''masterkey''');
   IBDatabase1.SQLDialect := 3;
   IBDatabase1.CreateDatabase;
end;

if you want to check if the DB is active do something like:

  if IBDatabase1.Connected then
    ShowMessage('opened');
0
 
LVL 10

Author Comment

by:kacor
ID: 17778696
This second works too. Thanks. Completely answered.

I outlined wrong my question. When I try to open an existing DB, my comment ID: 17777003 above is right unfortunately.
0
 
LVL 3

Expert Comment

by:cobi100
ID: 17781173
oh I see, well you can remove the params, and access directly through the properties of the ibconnection, something like:

   IBDatabase1.Params.Clear; //to clear the params
   IBDatabase1.Username := 'SYSDBA';
   IBDatabase1.Password := 'masterkey';
   IBDatabase1.SQLDialect := 3;
   IBDatabase1.Open;
0
 
LVL 10

Author Comment

by:kacor
ID: 17781539
Unfortunately this don't work. The debugger stops at lines

      IBDatabase1.Username := 'SYSDBA';
      IBDatabase1.Password := 'masterkey';

This is normal because they are parameters but the offered solution above for create database don't work too. I don't understand why accepts it for creating DB and for opening not.

Just a personal question: may I know your given name?

wbr Janos
0
 
LVL 3

Accepted Solution

by:
cobi100 earned 500 total points
ID: 17782577
I see, well the thing is that the lines I gave you use the IB script syntax, if you were to open an IBManager you could enter a command to create a db, and the user and password must be specified like that. now for opening it;s a dirrerent story, it would be great if you could try it with your own code.... just for open:

   IBDatabase1.Params.Clear;
   IBDatabase1.Params.Add ('user_name=sysdba');
   IBDatabase1.Params.Add ('password=masterkey');

Cheers

BTW. I'm Alex
0
 
LVL 10

Author Comment

by:kacor
ID: 17782687
Thanks Alex,

if you watch my original question I used this syntax to create a DB. I simply don't understand why have I to use different syntaxes for different commands. I have to to tell you I am only a "hobby" programmer - look at my member profile.

Again thank you for your support!

with best regards
Janos
0
 
LVL 3

Expert Comment

by:cobi100
ID: 17785536
I'm glad it worked

-Alex
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 124
creating threads in delphi 1 203
Base1 Encode/Decode 3 100
DBCtrlGrid, Delphi, Scroll 7 35
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 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