Print Page | Close Window

vb.net 2008 and Crystal 10 logon required

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2661
Printed Date: 16 May 2024 at 10:10pm


Topic: vb.net 2008 and Crystal 10 logon required
Posted By: dprima
Subject: vb.net 2008 and Crystal 10 logon required
Date Posted: 20 Mar 2008 at 6:05am
I have an app I'm migrating from vb.net 2003 to v2008.  I'm using the push model via SetDataSource to attach (bind) datasets from an Access database to a report at runtime.  This has been working fine in 2003 code.  Now, in v2008, I'm presented with a logon dialog box which fails no matter what I put in it.  I found some code which allows me to update the server name for the tables in the ReportDocument object (LogOnInfo.ConnectionInfo.ServerName), which I refresh by invoking the ApplyLogOnInfo method.  This gets me past the logon prompt.
 
However, now the data that shows on the report is not the data from the datasets, it's the data from the query that was used as the datasource when the report was originally designed.  This is not data that was saved with the report, as the report has no saved data.
 
I've included the code snippet with the relevant section below:
 
' mDS is a collection of DataSet objects.
' crvViewer is the Crystal Viewer control.
' gDataPath, gReportPath, mReportName are string variables.
' conDataDB is a string constant.

Dim cr As New ReportDocument
Dim i As Integer
Dim r As Integer
 
cr.Load(gReportPath & mReportName)
 
For i = 0 To cr.Database.Tables.Count - 1
   With cr.Database.Tables(i)
      .LogOnInfo.ConnectionInfo.ServerName = gDataPath & conDataDB
      .ApplyLogOnInfo(.LogOnInfo)
   End With
Next
 
cr.VerifyDatabase()
cr.Refresh()

If (Not mDS Is Nothing) Then
   cr.SetDataSource(mDS(1))
   For i = 2 To mDS.Count     '  if more than one dataset, for the report's subreports
      For r = 0 To (cr.Subreports.Count - 1)
         With cr.Subreports(r)
            If (mDS(i).Tables(0).TableName = .Database.Tables(0).Name) Then
               .SetDataSource(mDS(i))
               Exit For
            End If
         End With
      Next
   Next
End If
 
crvViewer.ReportSource = cr
 
I've tried moving the logon section (in red) to below the section binding the datasets, but it doesn't make a difference.
 
Thanks,
Dan



Replies:
Posted By: rodiel
Date Posted: 02 Sep 2008 at 2:38pm
Hey dan,
 
did you find a fix to this problem?



Print Page | Close Window