A follow up to this thread by ChickenLegWilly
I used the sample code provided by ComponentOne on this website and it is absolutely wrong. Oh, it works, sort of, until two different people try to print the report with different data simultaneously. It turns out that to prevent it from blowing up in a real world application, you must use session variable and include the SessionID in rendering and creating the report.
Code that works for me is as follows:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.C1ReportViewer1.Cache.Enabled = False
Me.C1ReportViewer1.Cache.ShareBetweenSessions = False
Session("rptpath") = HttpContext.Current.Server.MapPath("~/ReportLayout/OrderConfirmation.xml")
Session("rptname") = "OrderConfirmation"
Session("query") = "SELECT ..."
Session("FileName") = Session("rptname") + Session.SessionID.ToString()
Session("ReportName") = Session("rptname") + Session.SessionID.ToString() + "_" + Session("OrderNumber")
C1ReportViewer.RegisterDocument(Session("FileName"), AddressOf MakeDoc)
C1ReportViewer1.FileName = Session("FileName")
C1ReportViewer1.ReportName = Session("ReportName")
C1ReportViewer1.ExportedFileName = "Order " & Session("OrderNumber").ToString
Protected Function MakeDoc() As C1PrintDocument
Dim report As C1Report = C1ReportViewer.CreateC1Report()
report.DataSource.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyDatabase;Data Source=MySQLServerInstance"
report.DataSource.RecordSource = Session("query")
Catch ex As Exception
Me.lblRetryPrinting.Text = "A problem was experienced. Try to print using Account History"
When testing this Users no longer get each other's documents, but once every 5-6 attempts during testing, One user will get the correct document and the other user will get a blank preview that states the document was completely generated. Upon leaving the page an AJAX Error(0) is displayed.
The sad part is that it took over a month to get product support to understand the nature of the problem, and then 6 more weeks to get a reply with a sample that works so I could interpolate the correct way to do it . AND it is still not quite right, as mentioned above.