Board index » delphi » Multiple Database connections

Multiple Database connections

Dear Reader

I would like to write a program, that restores the data of a backup database
into the original database.

For this I wrote the following function. But when I execute the function the
message comes up, that the type for the field Xfis_T:MNU is unknown, but
Xfis_b is the database and MNU the tablename in the Xfis_b databas.
The manual for Delphi 1 wrote, that the : sign should preceed the database
name, but no change.

Do you have an hint.

procedure TfrmTransfer.BitBtn1Click(Sender: TObject);
var
 _sqlstr:  string;
 _inssql:  TStringList;
 _i:   integer;
begin
 try
  _inssql := TStringList.Create;
  try
   if (seTransfer.Active = False) then seTransfer.Active := True;
   if (Xfis_b.Connected = False) then Xfis_b.Connected := True;
   if (Xfis_T.Connected = False) then Xfis_T.Connected := True;

   sttTable.Caption := 'Menu';
   gaProgress.MinValue := 0;
   gaProgress.MaxValue := 1;
   gaProgress.Progress := 0;

   if (quBackup.Active = True) then quBackup.Active := False;
   if (quTest.Active = True) then quTest.Active := False;

   _sqlstr := 'Select * from MNU';
   quBackup.SQL.Clear;
   quBackup.SQL.Add(_sqlStr);
   quBackup.Active := True;

   _inssql.Add(' Insert into MNU (MNU_I, ACSRHT, MNUCRY, PGM, PGMNAM)');
   _inssql.Add(' Select MNU_I, ACSRHT, MNUCRY, PGM, PGMNAM from
:Xfis_b:MNU');

   for _i := 0 to _inssql.count -1 do
    quTest.SQL.Add(_inssql[_i]);

   quTest.ExecSQL;

   gaProgress.Progress := 1;
  finally
   _inssql.free;
  end;
 except on E: Exception do
  showmessage(E.Message);
 end;
end;

Thanks in advance.

Kind regards

Rene Heusser

 

Re:Multiple Database connections


Rene,

Now, it seemed you met a problem that you can't access multiple databases(SQL?)
in one sql statement.
First, what database are you using?
If you use a SQL database like Informix and others, you may connect to the
database server(something like to telnet to the unix server and run dbaccess for
example of Informix) and issue the sql there. I must mention three things:
1: The database server must be properly configued. If you failed to issue the
sql directly to the database server, you must check this.
2:The paramcheck property of the TQuery must be turned off.
2: One error I have met with informix is, the two database must all have /not
have logs.

Hope this helps.
Bye

Quote
Rene Heusser wrote:
> Dear Reader

> I would like to write a program, that restores the data of a backup database
> into the original database.

> For this I wrote the following function. But when I execute the function the
> message comes up, that the type for the field Xfis_T:MNU is unknown, but
> Xfis_b is the database and MNU the tablename in the Xfis_b databas.
> The manual for Delphi 1 wrote, that the : sign should preceed the database
> name, but no change.

> Do you have an hint.

> procedure TfrmTransfer.BitBtn1Click(Sender: TObject);
> var
>  _sqlstr:  string;
>  _inssql:  TStringList;
>  _i:   integer;
> begin
>  try
>   _inssql := TStringList.Create;
>   try
>    if (seTransfer.Active = False) then seTransfer.Active := True;
>    if (Xfis_b.Connected = False) then Xfis_b.Connected := True;
>    if (Xfis_T.Connected = False) then Xfis_T.Connected := True;

>    sttTable.Caption := 'Menu';
>    gaProgress.MinValue := 0;
>    gaProgress.MaxValue := 1;
>    gaProgress.Progress := 0;

>    if (quBackup.Active = True) then quBackup.Active := False;
>    if (quTest.Active = True) then quTest.Active := False;

>    _sqlstr := 'Select * from MNU';
>    quBackup.SQL.Clear;
>    quBackup.SQL.Add(_sqlStr);
>    quBackup.Active := True;

>    _inssql.Add(' Insert into MNU (MNU_I, ACSRHT, MNUCRY, PGM, PGMNAM)');
>    _inssql.Add(' Select MNU_I, ACSRHT, MNUCRY, PGM, PGMNAM from
> :Xfis_b:MNU');

>    for _i := 0 to _inssql.count -1 do
>     quTest.SQL.Add(_inssql[_i]);

>    quTest.ExecSQL;

>    gaProgress.Progress := 1;
>   finally
>    _inssql.free;
>   end;
>  except on E: Exception do
>   showmessage(E.Message);
>  end;
> end;

> Thanks in advance.

> Kind regards

> Rene Heusser

Other Threads