cancel
Showing results for 
Search instead for 
Did you mean: 

"Failed to open the connection" Error

Former Member
0 Kudos

Hi everyone,

I'm having some connection problems with Crystal XI and Visual Studio ASP.NET 2003.

I created the reports in my development server, they work perfectly there. Once I run them on my production server, the following error comes up:

Failed to open the connection. Details: [Database Vendor Code: 17 ] Failed to open the connection. C:\WINDOWS\TEMP\{6837BBAA-FD8A-410F-9171-12769D3B1782}.rpt Details: [Database Vendor Code: 17 ]

I don't use a CrystalReportViewer Object, Instead, I make my ReportDocument generate a PDF output.

As I said before, everything works fine on my development env and on other servers that can see the development server (any server in my network).

The reports use an OLEDB SQL Server connection pointing to the local machine.

When I run a report on the production server, it tries to connect to the development server (however, they cannot see each other), even though I set the right connection through code at runtime.

So I changed the way to connect to the database, Instead of using OLEDB I created an ODBC connection on both environment with the same name, changed the connections on the reports to use the new connection, but I kept having the same problem.

the application gets the connection information from web.config file:

//Get the connection information from Web.Config

Hashtable htConnection = Generic.StringToHashtable(ConfigurationSettings.AppSettings["ConnectionString"]);

//Set the connection

ConnectionInfo crConnectionInfo = new ConnectionInfo ();

crConnectionInfo.ServerName = htConnection["server"].ToString();

crConnectionInfo.AllowCustomConnection = true;

crConnectionInfo.DatabaseName = htConnection["database"].ToString();

crConnectionInfo.UserID = htConnection["uid"].ToString();

crConnectionInfo.Password = htConnection["pwd"].ToString();

//linking connections to the tables

foreach(CrystalDecisions.CrystalReports.Engine.Table table in crReportDocument.Database.Tables)

{

TableLogOnInfo tableLogonInfo = table.LogOnInfo;

tableLogonInfo.ConnectionInfo = crConnectionInfo;

table.ApplyLogOnInfo(tableLogonInfo);

}

//Generates PDF

MemoryStream oStream; // using System.IO

oStream = (MemoryStream)crReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

Response.Clear();

Response.Buffer= true;

Response.ContentType = "application/pdf";

Response.BinaryWrite(oStream.ToArray());

crReportDocument.Close();

crReportDocument.Dispose();

Response.End();

Can anyone help me?

Thanks

Jamal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Jamal,

please check a similar case under :

http://forums.asp.net/t/997655.aspx

and try the hints given there

Falk

Answers (1)

Answers (1)

Former Member
0 Kudos

Do the following steps:

1. Open the report in the CR XI designer.

2. Select Database -> Set Datasource Location.

3. Set Datasource Location window will appear and in the replace with section connect to the database and replace these tables with the tables in the current datasource by clicking the update button.

4. After updating close the Set Datasource Location window.

5. Go to 'Database menu' and Click 'Verify Database' and click on u2019OKu2019.

6. Preview the report and the save the report.