Subject Re: [IBO] How to work on IB Connections DropDatabase Command
Author Helen Borrie
At 12:13 AM 12/12/2006, you wrote:
>Hi ALL,
>I have a application which uses fb as its backend and Delphi as front
>end . I use IBObjects for connection to the FDB. My applicatation is
>structured in such a way that it can work for mulitiple companies.
>The is like this
>I have to create two companies A.LTD and B.LTD . The application will
>create two folders A and B . Now we have a template folder which has
>the Template.FDB. We will copy Template.FDB to each companies folder
>and put it ther with the same name .
>Now the problem that facing is that , our application has a delete
>company function . I have to delete the company .
> Eg : Say If i have to delete Folder A , i realesed all the
>IB_connection to A\Templae.FDB . I checked with connected usersd
>number too . It also returns 0 . For safety purpose i used
>forcedisconnect too . Now i tried to delete company , i get the error
>acess denied.
> I tried to use IBO connection DropDatabase . I set the Database
>name the tried to run dropdatabase . So i got the error that connection
>not established.
>When i put connected:=True i get the message Table is in use.
>Can anyone tell me how to use IBConnection.DropDatabse. If possible
>with a example.

You can write your own example.

1. Start a new project in Delphi.
2. Drop a TIB_Connection on the form and set its Server, Path and
Protocol properties. (In your real utility you will want to have the
SYSDBA input at least the Server and Path properties at the login
prompt, though.)
3. Set the Username property to SYSDBA and keep LoginPrompt true.
4. Drop in a button and apply this code:

procedure TForm1.Button1Click(Sender: TObject);
with IB_Connection1 do
if not Connected then Connect;
if Connected and (Uppercase(Username) = 'SYSDBA') then
Showmessage ('Database' + Path + ' successfully deleted.');
Showmessage ('Request denied. At least one connected user
has a pending operation.' );
Showmessage ('Request denied. You must log in as SYSDBA to
use this utility.');

Of course, this is an inherently fatal utility, so you will need to
build a lot more exception handling than is in this rough little
routine. You can look at the code that is called by the Drop
Database (cbDrop) button of the IB_ConnectionBar in the IB_SQL code
(IB_SQL.dpr in your IBO root folder) -- it is a much more
sophisticated implementation and it needs to be.