|
-
Oct 6th, 2005, 09:49 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Load a Report Programmatically
I got this code from a book but there are errors all over this:
VB Code:
Me.Cursor = Cursors.WaitCursor
Try
Dim oRpt As New ReportDocument
oRpt.Load("..\Reports\" & strTransaction)
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
For Each tbCurrent In oRpt.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = "localhost"
.UserID = "sa"
.Password = "corbin"
.DatabaseName = "BiWeekly"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
viewer.ReportSource = oRpt
Catch ex As Exception
MsgBox(ex.Message)
Finally
Me.Cursor = Cursors.Default
End Try
The errors are saying:
Cannot find custom tool 'CrystalDecisions.VSDesigner.CodeGen.ReportCodeGenerator' on this system.
Name 'viewer' is not declared
Name 'strTransaction' is not declared.
Type 'CrystalDecisions.CrystalReports.Engine.Table' is not defined
Type 'CrystalDecisions.Shared.TableLogOnInfo' is not defined
Type 'ReportDocument' is not defined
I need some advice how to resolve these issues.
Thanks.
Last edited by callydata; Oct 6th, 2005 at 10:03 AM.
-
Oct 6th, 2005, 02:14 PM
#2
Hyperactive Member
Re: Load a Report Programmatically
have you referenced your crystal report on your project?
-
Oct 6th, 2005, 02:23 PM
#3
Re: Load a Report Programmatically
Looks like your using vb.net with Option Explicit on. So you need to declare the strTransaction for starters. the rest of the problems will be fixed if you add the reference to Crystal and place the CR Viewer control on your form.
VB Code:
Me.Cursor = Cursors.WaitCursor
Try
Dim strTransaction As String
Dim oRpt As New ReportDocument
oRpt.Load("..\Reports\" & strTransaction)
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
For Each tbCurrent In oRpt.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = "localhost"
.UserID = "sa"
.Password = "corbin"
.DatabaseName = "BiWeekly"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
viewer.ReportSource = oRpt
Catch ex As Exception
MsgBox(ex.Message)
Finally
Me.Cursor = Cursors.Default
End Try
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|