简体   繁体   中英

Failed to open the connection Crystal Reports

I am using Visual Studio 2017 and SQL Server 2017 and the last version of Crystal Reports. I then create a stored procedure in SQL Server and a new report in Visual Studio (C#) using the code to get the connection info from the app.config .

When I try to make the program work in PC client, I have the problem failed to open connection temp - the error is illustrated in the screenshot below.

This is the code for the connection info:

SaleReportCrystal aLL_PUSH_STUDENTS = new SaleReportCrystal();
System.Data.Common.DbConnectionStringBuilder builder = new System.Data.Common.DbConnectionStringBuilder();

builder.ConnectionString = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString; ;

string server = builder["Data Source"] as string;
string database = builder["Initial Catalog"] as string;
string UserID = builder["User ID"] as string;
string password1 = builder["Password"] as string;

aLL_PUSH_STUDENTS.SetDatabaseLogon(UserID, password1, server, database);

ReportPrint studentInforamtionRep = new ReportPrint();
studentInforamtionRep.crystalReportViewer1.ReportSource = aLL_PUSH_STUDENTS;
studentInforamtionRep.ShowDialog();

Error:

图片

That error code (17) means: "Server does not exist or access denied."

Hopefully, that should point you in the right direction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM