
Connect to 2 different SQL Server 6.5 db
This is my problem:
In an application, I can' t connect to a datatabase different from the
one used to build the report (both the Databases are Sql Server 6.5).
The code of the application is written in C++ Builder 1.0 and is :
---beginning of code
void __fastcall TfrmFRag::menuSchedeProd1Click(TObject *Sender)
{
// Report Schede Prodotti. La selezione solo su Fam_id.
TSheetRect SelRect;
int icodProd;
int icodStab;
char *reportFile;
AnsiString sValue;
short Job;
short NameReport;
short tableN;
struct PELogOnInfo logOnInfo;
BOOL propagate;
sWhere ="";
tableN = 3;
propagate = true;
// Get information on the second table in the report
// Initialize size of structure
if (PEOpenEngine()==0)
{
PEOpenEngine()==1;
}
lstrcpy(reportFile,
"D:\\CriProgetti\\Bp\\CBuilder\\RPTBP_MASTSCHEDE_PROD.RPT");
Job = PEOpenPrintJob(reportFile);
if (Job <= 0){
// Handle error
Quote:
}
logOnInfo.StructSize = PE_SIZEOF_LOGON_INFO;
if (!PEGetNthTableLogOnInfo(Job, tableN, &logOnInfo)){
// Handle error
Quote:
}
//PESetNthTableLogOnInfo
// Log on only valid for the first table.
// Initialize structure
logOnInfo.StructSize = PE_SIZEOF_LOGON_INFO;
lstrcpy(logOnInfo.ServerName, "BP_ABBIGLIAMENTO");
lstrcpy(logOnInfo.DatabaseName, "BP_ABBIGLIAMENTO");
lstrcpy(logOnInfo.UserID, "sa");
lstrcpy(logOnInfo.Password, "");
if (!PESetNthTableLogOnInfo(Job, tableN, &logOnInfo, propagate)){
// Handle error
Quote:
}
if (pcFilter->ActivePage->PageIndex == 0)
{
if (grdView->ColCount > 1)
{
for(int i= -1; i<grdView->SelCount;i++)
{
if (i== -1)
SelRect = grdView->Selection;
else
SelRect=grdView->SavedSelection[i];
for (int j=SelRect.Top;j<=SelRect.Bottom;j++)
{
sValue = grdView->Cells[1][j]; // colonna 1 = fam_id.
sWhere = sWhere + " {Query.BPF_FAM_ID} = ('" +
sValue + "') OR ";
}
}
sWhere = sWhere.SubString(0,sWhere.Length()-3); //Per
eliminare l'OR alla fine.
Close();
}
}
//**************************************************************************
//Open report.
//**************************************************************************
//Per Provarlo.Ora il report in locale nella stessa dir in cui ho
l'exe del progetto.
CryRep->ReportFileName="RPTBP_MASTSCHEDE_PROD.RPT";
//La formula di selezione records,definita in design, deve venire
modificata.
CryRep->Formulas[0] = "SELQuery = " + sWhere;
CryRep->Action = 1;
Quote:
}
---end of code
If I could not change runtime the Database for the report data all my
work will be pointless.
thank you
Cristina Falzoni.