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
Solved

TIBDatabase Create/Open Database - D7

Posted on 2006-10-19
11
2,701 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…

791 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