When you start playing with Crystal Reports in VS, it pops up annoying dialog asking to register.
Bad news: you have to do it, otherwise you won't be able to deploy the application using these reports, google for KeycodeV2.dll.
Good news: registration is free.
As for deployment there is another gotcha: by reading documentation you might think that you can change report data source by using
ReportDocument.SetDatabaseLogon. It didn't work for me, what did work is setting datasource on each table in the report:
CrystalDecisions.Shared.TableLogOnInfo tliCurrent = null;
foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in reportDocument.Database.Tables)
{
tliCurrent = tbCurrent.LogOnInfo;
tliCurrent.ConnectionInfo.ServerName = "SERVERNAME";
tliCurrent.ConnectionInfo.UserID = "USERID";
tliCurrent.ConnectionInfo.Password = "PASSWORD";
tliCurrent.ConnectionInfo.DatabaseName = "Northwind";
tbCurrent.ApplyLogOnInfo(tliCurrent);
}
No comments:
Post a Comment