Solved

linking Database with Multi-user design

Posted on 2002-04-25
10
192 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now