on 07-17-2021 9:38 AM
I have a report made with Crystal Reports 2020, I connected it with local Postgres Database using JDBC. It's successful.
Now, I want to print report output with C#(.Net Framework 4.8), I tried every variant, but it wasn't successful. I have got error:"Failed to load database information.".
My server parameter is most probably wrong,I dont know maybe it's right but other parameters are wrong .I searched it ,read lots of sources but I didn't solve it. How do I change a Crystal Report's JDBC connection parameters?
My last code:
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"C:\Users\AtillaAliyev\Desktop\ActuerialProject\ActuerialReports\DeathPRM.rpt");
CrystalDecisions.Shared.ConnectionInfo myConnectionInfo = new CrystalDecisions.Shared.ConnectionInfo();
myConnectionInfo.ServerName = "Driver = {org.postgresql.Driver}; Server=jdbc:postgresql://localhost;Port=5432;";
myConnectionInfo.DatabaseName = "ActuerialCalculationAPIDatabase";
myConnectionInfo.UserID = "postgres";
myConnectionInfo.Password = "admin";
foreach (CrystalDecisions.CrystalReports.Engine.Table item in cryRpt.Database.Tables)
{
TableLogOnInfo t = item.LogOnInfo;
t.ConnectionInfo = myConnectionInfo;
item.ApplyLogOnInfo(t);
}
cryRpt.SetParameterValue("report_id", 1);
cryRpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"C:\Projects\test1.pdf");
}
}
}
Open the report in CR Designer, make the connection and then expand the connection properties in Set Location...
You'll see the values required.
Likely cause is the Connection name is wrapped in { }, remove them in your Server Name:
{org.postgresql.Driver}
should be
org.postgresql.Driver
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.