Solved

linking Database with Multi-user design

Posted on 2002-04-25
10
197 Views
Last Modified: 2010-04-04
Please help me accessing this one. where can i find the
"DATABASE.GDB" file? and how can i put password on it?
what do "IB_SERVER" mean and what is this? can anybody teach me how to make a ".GDB" FILE and to add new tables inside

var

MyList: TStringList;
begin
MyList := TStringList.Create;
try
with MyList do
begin
Add('SERVER NAME=IB_SERVER:/PATH/DATABASE.GDB');
Add('USER NAME=MYNAME');
end;
Session1.AddAlias('NewIBAlias', 'INTRBASE', MyList);
finally
MyList.Free;
end;
end;
0
Comment
Question by:girlswants_me
[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
  • 3
  • 2
  • 2
  • +2
10 Comments
 

Author Comment

by:girlswants_me
ID: 6967885
help me please
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6967914
Interbase is a database server: http://www.borland.com/interbase/
You can create databases, tables, data in it using SQL.
0
 

Author Comment

by:girlswants_me
ID: 6967923
my question in how to use that "code" and how to access the GDB file
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 8

Expert Comment

by:TOndrej
ID: 6967959
You were asking "where you can find database.gdb file" and "how to put password on it" so I assume you have no idea what you want and gave you the link to interbase site where you can start learning.

If you have Interbase installed then read the documentation which tells you precisely how to login to the server, create databases, attach to them and work with tables.

The code you posted seems to use BDE TSession component to create an alias using BDE INTRBASE driver.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6967965
listening . . . firsttime :-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6967967
hi tondrej ;-)
0
 
LVL 4

Expert Comment

by:nestorua
ID: 6969384
HI,
First of all, I assume you have ibserver (ibguard)
(Interbase Server and/or Interbase Gardian) running on your
computer.
Then you can go to f.e. SQL Explorer and open IBLocal (alias)
using User=SYSDBA and password=masterkey.
IBLocal must point to the file
\..borland shared\data\employee.gdb.
Then you open this db and can work on it.
If you want to create your own ".gdb" file you must launch the
WISQL (Interbase windows ISQL) and using SQL language create
your database (create database, create table and so on).
That's all.
Sincerely,
Nestorua.
0
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 100 total points
ID: 6970595
Here's the code I use to create an Interbase database from within Delphi.  It also allows you to add an alias to the BDE as well.

procedure TCreateIBDataseForm.CreateDatabase;
var
  Params: TStringList;
begin
  try
    IBDatabase.DatabaseName := IBDBPathEdit.Text;
    IBDatabase.Params.Clear;
    IBDatabase.Params.Add('USER "' + UsernameEdit.Text + '"');
    IBDatabase.Params.Add('PASSWORD "' + PasswordEdit.Text + '"');
    IBDatabase.Params.Add('PAGE_SIZE ' + PageSizeEdit.Text);
    IBDatabase.CreateDatabase;
    if CreateNewAliasRadio.Checked then
      begin
       Params := TStringList.Create;
        try
          try
            Params.Add('SERVER NAME=' + IBDBPathEdit.Text);
            Params.Add('USER NAME='+ UsernameEdit.Text);
            Session.AddAlias(AliasNameEdit.Text, 'INTRBASE', Params);
            Session.SaveConfigFile;
          except
            on E: Exception do
              MessageDlg('An error was generated while attempting to create '+
                '+the new Interbase database'+#13+ E.Message, mtError, [mbOK], 0);
          end;
        finally
          Params.Free;
        end; {try..finally}
      end; {if CreateNewAliasRadio}
    Close;
  except
    on E: Exception do
      begin
        if MessageDlg('An error has occurred: ' + #13 + e.Message + #13 +
          'Would you like to roll back and try again?',
          mtError, [mbYes, mbNo], 0) = mrNo then
            Exit;

        try
          DeleteFile(IBDBPath.Text);
        except
        end;

        try
          Session.DeleteAlias(AliasNameEdit.Text);
          Session.SaveConfigFile;
        except
        end;

      end;
  end; {try..except}
end; {OKButtonClick}

IBDatabase is a TIBDatabase component located on the Interbase tab within Delphi.

IBDBPathEdit, UsernameEdit, PasswordEdit, PageSizeEdit,
AliasNameEdit are all edit boxes.  There names are self explanatory.

CreateNewAliasRadio is a radio button.  There's two of them : CreateNewAliasRadio and DoNotCreateNewAliasRadio

Once you have created your database using this procedure, you can open it using a TQuery and then execute SQL against it.

For instance, to create this table:

FIRSTNAME   STRING LENGTH 50
LASTNAME    STRING LENGTH 50
PHONENO     STRING LENGTH 25
POSTCODE    STRING LENGTH 8
NUMBOFEYES  INTEGER

You would do this:

CREATE TABLE PERSONALDETAILS (
FIRSTNAME CHAR(50),
LASTNAME CHAR(50),
PHONENO CHAR(25),
POSTCODE CHAR(8),
NUMBOFEYES INTEGER)

You don't call Query.Open either, you call Query.ExecSQL when creating, altering, dropping, inserting or updating tables.

Hope this helps,

Stu
0
 

Author Comment

by:girlswants_me
ID: 6970674
Thank you for such a brilliant answer.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6970731
No problems at all :)  Just let me know if you have any more problems with the code or answer.

Stu
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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

737 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