If CRVS is to be used in the development of Visual Studio-based software products, one must be able to dynamically set the report data sources at runtime.
However, I have found no clear way to do this, in either the documentation or on the web.
Say it isn't so !!
TIA, Karl

Change Report Datasource at Runtime ???????
Jurgen Willis
Karl, it ain't so!
You can, indeed, change the data source at run time. In fact there are numerous articles on the web to support this as well as several walk throughs on both MSDN and BusinessObjects websites.
My favorit of course is Crystal Reports For Visual Studio 2005 - Data Connectivity Tutorial: Connecting to Object Collections. I am a big fan of object collections as I can pass them around applications and web sites simply.
When I googled "Crystal Reports" "Data source" runtime it returned 69,100 results... So it ain't so Karl.
If you give more detail on what you are trying to accomplish I would be happy to give you some sample code.
Regards,
Jeff
DEVSOUTH, Inc.
Yun yang
With this code I'm assuming the new command would need the same parameters as the original (if it has parameters). If you're jogging between commands that have different parameters, that would probably be a more complex undertaking.
*
'set connection information
Dim cryTable As CrystalDecisions.CrystalReports.Engine.Table
Dim cryConnInfo As New CrystalDecisions.Shared.ConnectionInfo
Dim cryLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
cryConnInfo.ServerName = strSqlServer
'cryConnInfo.DatabaseName = "cbase" 'hardcode
For Each cryTable In rptDoc.Database.Tables
Try
cryLogonInfo = cryTable.LogOnInfo
cryLogonInfo.ConnectionInfo = cryConnInfo
cryTable.ApplyLogOnInfo(cryLogonInfo)
cryTable.Location = cryTable.Location.Substring(cryTable.Location.LastIndexOf(".") + 1)
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Next
End Sub
Jimme
Gilles Muys
http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=85770&SiteID=1
C#:
CrystalReport1 crReport = new CrystalReport1();
ConnectionInfo crConInfo = new ConnectionInfo();
crConInfo.ServerName= "ServerName";
crConInfo.DatabaseName = "DBname";
crConInfo.UserID = "UID";
crConInfo.Password = "PWD";
TableLogOnInfo crLogInfo = new TableLogOnInfo();
crLogInfo.ConnectionInfo = crConInfo;
crReport.Database.Tables[0].ApplyLogOnInfo(crLogInfo);
Karl