I have an ASP.Net web form.
I have Crystal Reports for .NET Framework 4.0.
I have a test database with one table that has one column. I'm using the 'sa' login.
The page has the code below. There is a basic CrystalReportViewer control on the page.
When I preview the report in Visual Studio it shows real data correctly.
When I view the page I see this:
Failed to open the connection. Details: [Database Vendor Code: 17 ] Failed to open the connection. CrystalReport1 {6CDF6401-23A1-45C0-AC81-7EEAC508ABA4}.rpt Details: [Database Vendor Code: 17 ]
Apparently "Database vendor code 17" means "server does not exist or access denied" yet if I use the same settings and connect directly via ADO.Net code it works first time, every time.
It's been two days now: I've never wasted so much time getting a product to connect to a MSSQL DB.
protectedvoid Page_Load(object sender, EventArgs e)
{
ReportDocument cryRpt = newReportDocument();
TableLogOnInfo crtableLogoninfo = newTableLogOnInfo();
ConnectionInfo crConnectionInfo = newConnectionInfo();
Tables CrTables;
cryRpt.Load(Server.MapPath("CrystalReport1.rpt"));
crConnectionInfo.ServerName = "localhost";
crConnectionInfo.IntegratedSecurity = false;
crConnectionInfo.DatabaseName = "Test1";
crConnectionInfo.UserID = "sa";
crConnectionInfo.Password = "xxxxxxxx";
CrTables = cryRpt.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
crtableLogoninfo = CrTable.LogOnInfo;
crtableLogoninfo.ConnectionInfo = crConnectionInfo;
CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
}
David