Solved

linking Database with Multi-user design

Posted on 2002-04-25
10
195 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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