cancel
Showing results for 
Search instead for 
Did you mean: 

DataSourceException in some case

0 Kudos
90

Hi,

I have a complex case with error : "DataSourceException :La table BTS est introuvable.... Impossible de trouver la table."

In english : "Table BTS was not found .... Can not find the table".

We have this error in the last version of our program and we can not find what change can produce this error (nothing change in our printing code).

Our report works fine crystal report designer, the preview can display data and there is no problem.

But in our code, when we make a reportDocument.ExportToDisk or ExportToStream there is the error.

We already try to update crystal report but there is no change.

We have two versions of our program, one in C# in windows form with a client part and server part (the server part load report and this is in this part that we have error). The other version is web in asp, javascrip and angular. In the web part, the crystal report viewer is hable to display data but can not export to pdf ... I think that it is for the same reason. The server part is used by the web version and the client version.

Another case who work is when we create a report with a dataset, when we do like this everything works. It is only with report with direct sql connexion that we have problems.

It is like something block the SQL connection to crystal report and that can maybe explain the reason why crystal don't see the table. Have you an idea of whitch case display this error?

Thank you.

Gwenaël.

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

Hi, I found the problem, it is a confilct between crystal report a dll called sqlKata that we add in our project.

0 Kudos

Hi, I tried to make a simple project called "TestCrystal". When I use It alone no error.

Then I add it in the solution of the project who has error.

If launch "TestCrystal" has starting project no problems it works.

If I add in the main of the project called "Client" (who is normaly the starting project) this code I have the error:

FormTestImpression formTest = new FormTestImpression();  Application.Run(formTest);

FormTestImpression is this only one winform of "TestCrystal" and it has only a button who load a crystal report.

The code to get report (report.ExportToStream get the error only in the case describe before).

public void getEtat()
{
var report = new ReportDocument();
report.Load("E:\\DEV\\Mainti\\ServImpression\\20130000SansParam.rpt");
ApplyLoginInfo("sql.tribo.local\\sql2017", "GLB_Test", "sa", "xxxx", report);
Stream s = report.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
}

private static void ApplyLoginInfo(string serverName, string databaseName, string userId, string password, ReportDocument document)
{
var info = new TableLogOnInfo();

info.ConnectionInfo.AllowCustomConnection = true;
info.ConnectionInfo.ServerName = serverName;
info.ConnectionInfo.UserID = userId;
info.ConnectionInfo.Password = password;

info.ConnectionInfo.DatabaseName = databaseName;

document.SetDatabaseLogon(info.ConnectionInfo.UserID, info.ConnectionInfo.Password, info.ConnectionInfo.ServerName, info.ConnectionInfo.DatabaseName, false);

foreach (IConnectionInfo connection in document.DataSourceConnections)
{
connection.SetConnection(serverName, databaseName, false);
connection.SetLogon(userId, password);
connection.LogonProperties.Set("Data Source", serverName);
connection.LogonProperties.Set("Initial Catalog", databaseName);
}

foreach (Table table in document.Database.Tables)
{
TableLogOnInfo tableLogOnInfo = table.LogOnInfo;
tableLogOnInfo.ConnectionInfo = info.ConnectionInfo;
table.ApplyLogOnInfo(tableLogOnInfo);
}

if (!document.IsSubreport)
{
foreach (ReportDocument rd in document.Subreports)
{
ApplyLoginInfo(serverName, databaseName, userId, password, rd);
}
}
}

I think that there is a problem in some configurations of the "Clien" project or solution but what can have this impact on crystal report?

DellSC
Active Contributor
0 Kudos

What credentials are you using to log in to the database from your code? Have you tried running the report in the Crystal designer using those credentials? I suspect that there is something happening with the security in the database that is causing Crystal to not be able to find the table.

-Dell