Solved

TIBDatabase Create/Open Database - D7

Posted on 2006-10-19
11
2,711 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
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!

 
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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 124
How to define IfThen functions in one common unit? 4 62
scroll down TListBox component in Delphi 1 30
DBCtrlGrid, Delphi, Scroll 8 55
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

735 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