connect string in frxSDACDatabase just before ShowReport (FastReport 3)

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
mfg
Posts: 10
Joined: Wed 03 Oct 2007 13:49
Location: Zabrze

connect string in frxSDACDatabase just before ShowReport (FastReport 3)

Post by mfg » Mon 08 Oct 2007 19:47

Hello,
I have a problem with setting a connect string in frxSDACDatabase object.
When I design report I've got a connect string for my local database and ShowReport works ok, but when I send this report to my clients there is neccesary to set a connect string to MSConnection.ConnectString.
I've got a frxSDACComponents1.DefaultDatabase set on MSConnection, but when FastReport.ShowReport is called, a FastReport tried to connect to my local database.
Is it possible to set this connection string just before method FastReport.ShowReport ? I tried to set this string when OnStartReport is called, but it is to late.

kind regards
Zbigniew Sorokowski

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 10 Oct 2007 12:01

You can set connection parameters in the BeforeConnect event of your MSConnection.

You can also show the connect dialog to let a user enter the connection settings. Make sure that the LoginPrompt property of TMSConnection is set to True, and the SDACVCL unit is added to the uses clause of the unit.

mfg
Posts: 10
Joined: Wed 03 Oct 2007 13:49
Location: Zabrze

Post by mfg » Wed 10 Oct 2007 21:46

thank you for your answer, but the problem is that I have to set 2 connection strings - one is MSConnection and I have it in DataModule/Delphi - and with this connection I haven't got any problems.

Second connection is directly in filereport.fr3 - I mean frxSDACDatabase.

I try to something like this (on client side):
ShowMessage(DataModule.MSConnection1.ConnectString); // here I see proper client connect string, I'm connected to database
FastReport.LoadFromFile('filereport.fr3'); -> in this file I have frxSDACDatabase object with my local properties like server, user and so on. When I prepare this fr3 file on my side I don't know how it has to be set on client side
FastReport.ShowReport; // here I have error message 'SQL Network Interfaces: Error locating Server/Instance Specified' because frxSDACDatabase try to connect to my locale database

My problem is - how to do this:
frxSDACDatabase.Server := DataModule.MSConnection1.Server
...
just before
FastReport.ShowReport;
I thought that it is enough to set
frxSDACComponents1.DefaultDatabase := DataModule.MSConnection1
but it isn't.

Maybe I do something wrong, but I couldn't find any manual which describe this subject - on this forum and FastReport either.

ZS

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 11 Oct 2007 14:51

You can try to remove the frxSDACDatabase from your report and put the following line of your code just before you call to FastReport.ShowReport:

Code: Select all

  frxSDACComponents1.DefaultDatabase := DataModule.MSConnection1;
In this case DataModule.MSConnection1 should be caught by your FastReport.

mfg
Posts: 10
Joined: Wed 03 Oct 2007 13:49
Location: Zabrze

Post by mfg » Fri 12 Oct 2007 16:40

I removed the frxSDACDatabase, and now it works.
Thank you for your help.

ZS

Post Reply