Solved

Crystal Reports 2016 Failed to open the connection Database Vendor Code 17, Error creating new data source

Posted on 2016-07-27
1
168 Views
Last Modified: 2016-07-29
Hi
 I'm trying to fix drilldown reports open connection failed error , this only appears on aspx.vb postbacks, either through page navigation or through drill down. Appreciate if you could help me resolve this issue.

 Regards,
 Member_2_7969420
CrystalReportError.png
0
Comment
Question by:Member_2_7969420
1 Comment
 
LVL 6

Accepted Solution

by:
Manju earned 500 total points
ID: 41733153
This is a common problem with embedding Crystal Reports in ASP pages. Essentially, the authentication details are reset on a postback and need to be reassigned in the Page_Init handler.

First, import these:

Imports CrystalDecisions.Shared
Imports CrystalDecisions.CrystalReports.Engine

Open in new window


Then, in the Page_Init handler, re-apply connection info:

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim myReport As New ReportDocument()
myReport.Load(Server.MapPath("ReportName")) -- name of the crystal report

Dim myTables As Tables = myReport.Database.Tables

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
  Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo
  myConnectionInfo.ServerName = "" -- <SQL servername>
  myConnectionInfo.DatabaseName = "" -- leave database name blank
  myConnectionInfo.UserID = "" -- username
  myConnectionInfo.Password = "" -- password
  myTableLogonInfo.ConnectionInfo = myConnectionInfo
  myTable.ApplyLogOnInfo(myTableLogonInfo)
Next

CrystalReportViewer1.ReportSource = myReport

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question