|
-
Feb 16th, 2005, 12:19 AM
#1
Thread Starter
Addicted Member
how to call report from crystal report with out using Crystal report viewer in vb.net
Hi all!
I have a report in the crystal report tool not in the vb.net.
and i save it and a report file.but i do not know how to call this report file for printpreview/print by vb.net not use .net crystal report viewer tool?
did you have some solution and the sample code for this problem?
i hope this problem will solve.
best regards,
thirith.
Last edited by thirith; Feb 17th, 2005 at 12:25 AM.
-
Feb 16th, 2005, 01:06 AM
#2
Re: how to call report from crystal report with out using Crystal report viewer in vb.net
I just wrote this example for someone today. It is in VB6 syntax but it should help you. The database
backend s for SQL Server but its similar for Access.
VB Code:
Option Explicit
'Add references to:
'Crystal Reports Viewer Control
'Crystal Reports 8.5 ActiveX Designer Run Time Library
'Crystal Reports 8.5 Library
'Microsoft ActiveX Data Objects 2.x Library
Private moApp As CRAXDRT.Application
Private moReport As CRAXDRT.Report
Private moCnn As ADODB.Connection
Private moRs As ADODB.Recordset
Private Sub Command1_Click()
Set moRs = New ADODB.Recordset
moRs.Open sSQL, moCnn, adOpenKeyset, adLockOptimistic, adCmdText
If moRs.BOF = True And moRs.EOF = True Then
MsgBox "No Record(s) returned!", vbOKOnly + vbExclamation
Else
Dim sUserName As String
Dim sUserName As String
Dim sUserPwd As String
Dim sServer As String
Dim sDatabase As String
Dim sPara1 As String
Dim sPara2 As String
Set moReport = New CRAXDRT.Report
Set moReport = moApp.OpenReport(App.Path & "\MyReport.rpt", 1)
sUserName = "MyUserName"
sUserPwd = "mypassword"
sServer = "ServerName"
sDatabase = "DatabaseName"
sDriver = "P2SSQL.DLL"
moApp.LogOnServer "P2SSQL.DLL", sServer, sDatabase, sUserName, sUserPwd
moReport.Database.Tables(1).SetLogOnInfo sServer, sDatabase, sUserName, sUserPwd
moReport.ParameterFields.Item(1).ClearCurrentValueAndRange
moReport.ParameterFields.Item(1).AddCurrentValue sPara1
moReport.ParameterFields.Item(2).ClearCurrentValueAndRange
moReport.ParameterFields.Item(2).AddCurrentValue sPara2
moReport.Database.SetDataSource moRs, 3, 1
CRViewer1.ReportSource = moReport
CRViewer1.ViewReport
CRViewer1.ShowFirstPage
End If
End Sub
Private Sub Form_Load()
Dim sSQL As String
Dim sDB As String
Dim sServer As String
sSQL = "SELECT * FROM Table1 WHERE Something = SomethingElse;"
sDB = "MyDatabase"
sServer = "MyServer"
Set moCnn = New ADODB.Connection
moCnn.ConnectionString = "provider=sqloledb;data source=" & sServer & ";initial catalog=" & sDB & ";integrated security=sspi;"
moCnn.Open
End Sub
HTH
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 
-
Feb 16th, 2005, 04:25 AM
#3
Thread Starter
Addicted Member
Re: how to call report from crystal report with out using Crystal report viewer in vb.net
Thanks RobDog888
the code that post is solved my problem by using this code.
Thirith.
-
Feb 16th, 2005, 12:00 PM
#4
Re: how to call report from crystal report with out using Crystal report viewer in vb.net
Glad to have helped , but I knowI posted an ex using the viewer control, but you
stated that you didnt want to use it. Just a little thats all.
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
|