Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TIBDatabase Create/Open Database - D7

Posted on 2006-10-19
11
Medium Priority
?
2,785 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 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