Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
| Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2003, 05:33 PM
Registered User
 
Join Date: Jun 2003
Location: Vancouver, WA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dimondwoof
Default Accessing a CR from VB.NET

I'm trying to update the record source for my report from my VB.NET application. This is the code I'm using:

Public Function SetReportConnection(ByVal oRpt As ReportDocument) As ReportDocument

Try
  Dim crTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo
  Dim crConnectionInfo As CrystalDecisions.Shared.ConnectionInfo
  Dim crTable As Table
  Dim strName As String

  crTableLogonInfo = New TableLogOnInfo()
  crConnectionInfo = New ConnectionInfo()

  crConnectionInfo.ServerName = clsSQLLogin.strServerName
  crConnectionInfo.DatabaseName = clsSQLLogin.strDB
  crConnectionInfo.UserID = clsSQLLogin.strUserName
  crConnectionInfo.Password = clsSQLLogin.strPassWord
  crTableLogonInfo.ConnectionInfo = crConnectionInfo

  For Each crTable In oRpt.Database.Tables
    crTable.ApplyLogOnInfo(crTableLogonInfo)
  Next

  Try
    strName = oRpt.Database.Tables(0).Location.ToString
    oRpt.Database.Tables(0).Location = strName
  Catch ex As Exception
    MessageBox.Show(ex.Message & ex.GetType.ToString)
  Finally
    SetReportConnection = oRpt
  End Try
Catch ex As Exception
  MessageBox.Show(ex.Message & ex.GetType.ToString)
End Try
End Function

The lines regarding getting and setting the Location were given to me by Crystal Decisions help and work MOST of the time. It is apparently required to force the report to update it's record source. However, I have a report that was working great and all of a sudden, it gets to that line and just hangs. No error message, the program just stops responding. Does anyone have any better idea on how to handle this?
 
Old June 24th, 2003, 10:27 AM
Registered User
 
Join Date: Jun 2003
Location: Vancouver, WA, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to dimondwoof
Default

Well, come to find out it wasn't hanging. The problem was that I have the report based on A SQL stored procedure. Apparently, when you set the location of a CReport, it touches the source (or Location, as they call it) and queries it for a structure. Because the stored procedure takes so long to run when you don't pass it any parameters (which apparently you can't when setting the location), it was taking about 10 minutes to even open the report window. This is before it would re-query the source based on the filters applied.

The solution: I set a "@GetData bit = 0" parameter in the stored procedure and then when I call the report, I pass it a 1. If the variable is set to 0 in the sp, I return a recordset "SELECT * FROM tblSourceTable WHERE 1 = 0". That way it would return the structure almost instantly.




Similar Threads
Thread Thread Starter Forum Replies Last Post
VB.NET - creating a CR report at run time jimbodeni Crystal Reports 4 March 21st, 2013 10:01 AM
Installation vb.net windows application with CR. saket123 .NET Framework 2.0 0 August 12th, 2008 11:44 PM
Deploy CR with Visual Studio 2005 VB.Net clflyer Crystal Reports 0 March 7th, 2007 12:41 PM
Dynamic images from VB .net to CR .net. Given Path Alita Crystal Reports 0 September 22nd, 2004 01:51 AM
CR in VB.Net Using Large Data Table seabiscuit Crystal Reports 1 July 7th, 2004 12:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.