Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Database Logon

Status
Not open for further replies.

ddnh

Programmer
Nov 25, 2002
94
US
I have a report connected to two datasources. A SQL DB and an Oracle DB. I am using a C#.net app to run the reports. In other reports using the same datasources, just one at a time, I can add the logon info and the user never has to enter logon info. How do I do it for two datasources? Here is the code I use for one. I tried just doubling the code, adding a 2 for the second set (instead of crDatabase I used crDatabase2 and so on), and changing the db/password info....but it didn't work. I also tried just entering the info for one DB, hoping to at least set one and only be prompted for one. With both attempts I get an error: "Error in file C:\DOCUME~\....\Temp\temp.......rpt: The table could not be found.

Any suggestions?
*********************************

public class frmOutstandingChecksParam

//Database Authentication

private Database crDatabase;
private Tables crTables;
private Table crTable;
private TableLogOnInfo crTableLogOnInfo;
private ConnectionInfo crConnectionInfo = new ConnectionInfo ();

//End

*********************************

private void btnShow_Click(object sender, System.EventArgs e)
{
crConnectionInfo.ServerName = "acct01";
crConnectionInfo.DatabaseName = "CompanyI";
crConnectionInfo.UserID = "userID";
crConnectionInfo.Password = "Password";
crReportDocument.SetDatabaseLogon("userID","Password");

crDatabase = this.crReportDocument.Database;
crTables = crDatabase.Tables;

for (int i = 0; i < crTables.Count; i++)
{
crTable = crTables ;
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
}

{
frmOutstandingChecksViewer frm = new frmOutstandingChecksViewer();
frm.vwrOutstandingChecks.ReportSource = crReportDocument;
frm.Show();
}
}
 
Perhaps you'll be best served to use MS Access to link the 2 data sources, and then create a MS Query against both data sources to be used as the data source for Crystal.

-k
 
Thanks for the suggestion, but we're trying to stay away from adding another application to the mix.

Anyone have a suggestion to access the data as is?
 
I think Crystal's usual suggestion for this (besides what k suggested) is to use a linked subreport to access the second data source. That way, you set the logon info for the main report, then set different logon info for the subreport, and they should play nice.

Does ADO.Net support linking different types of data sources? If so, you might be better served to create the dataset in C#, and send that to the report at runtime.

-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top