Tuesday, March 6, 2012

.Net 2003 access Crystal Report XI: Error:Failed to open the connection: [Database Vendor Code:

I am receving this error: Failed to open the connection: [Database Vendor Code: 17 ], from .Net 2003/C# to Crystal Report XI with SQL Server 2000 has backend database.

Is there a security permission that has been overlooked?

Here is the code I use to access CR XI

ConnectionInfo connectionInfo = new ConnectionInfo();
TableLogOnInfo tableLogOnInfo;
Database DB;
'CrystalDecisions.CrystalReports.Engine.Table' table;
Tables tables;

//Log in
connectionInfo.ServerName = "ServerName";
connectionInfo.DatabaseName = "Database Namet";
connectionInfo.UserID = "userid";
connectionInfo.Password = "password";

//Get Table inf from report
DB = reportDocument..Database;
tables = DB.Tables;


//Looping through all the tables in CR and apply connection info
for(int i = 0; i < tables.Count; i++)
{
table = tables[ i ];
tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);

}

CrystalReportViewer.ReportSource = ReportDocument.ReportSource;
CrystalReportViewer.Visible = true;

Any advise would be helpful.
Thank you

Hi, Koolaidbomber

First, try to find osql.exe on your client box, "c:\program files\microsoft sql server\80\tools\binn", osql.exe /S<servermachine> /E, or "osql.exe /S<servermachine>\<Instancename> /E"( the latter is for named instance). would you also get the same error? For remote connection specific you need following checklist:

A. Enable "File and printer sharing" in Firewall if your server is behind that.

B. Add program "sqlbrowser.exe" or udp port "1434" in your firewall exception list.

C. Add tcp port "1433" of default instance or <port number> of named instance in firewall, check you errorlog to figure out which port server is listening on. If you want your connection over TCP and make sure your server has TCP enabled.

D. Try ping your remote server machine, name and ipaddress.

E. Try to telnet <remoterservername> <portnumber>

F. Try to access a share of your remote server.

If above list all passed, you should be able to connect to linked server unless other problem exists, normally, you could see event log or server log to get clue.

Good Luck!

Ming.

|||Ming,

Thank you for your response. Will try it and let you know.

Thanks again|||Hey Ming,

I gave what you suggested a go, but I still get the error when I access CR XI from .Net 2003. I have connection to the DB server, and I am able to run the CR XI on a stand alone bases, but when it come to accessing from .Net 2003 Web App, I get the error.

Thank again for your idea|||

I recommend reading http://msdn2.microsoft.com/en-us/library/ms227528.aspx regarding how to setup Crystal Reports to connect to SQL Server tutorial.

Since are you able to run the CR XI on standalone, sounds like your Web App config is wrong.
Please post the config setting for your web app.

Jimmy

|||Hi Jimmy -

As requested, here is a copy of my web.config file

<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.web>

<compilation defaultLanguage="c#" debug="true"><assemblies><add assembly="CrystalDecisions.CrystalReports.Engine, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.ReportSource, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Shared, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Web, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Enterprise.Framework, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Enterprise.InfoStore, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/><add assembly="CrystalDecisions.Enterprise.Web, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/></assemblies></compilation>

<customErrors mode="RemoteOnly"/>

<authentication mode="Windows"/>

<authorization>
<allow users="*"/>

</authorization>

<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>

<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>

<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>

</system.web>

</configuration>

I will read over the documentation, and let you know if this error gets firgured out.

Thank you

No comments:

Post a Comment