473,698 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

connecting to Crystal subreports using vb.net

we have a vb.net app that displays a series of reports

this is all working fine when it is just one report, but if we have a report which contains a subreport then it fails, i assume you need to logon to the subreports also but im not sure how to.

the subreports also require 4 parameter values to be passed to it

any help would be greatly appreciated

Cheers,
Craig

here is the code we use for calling a single report
*************** *************** *************** ***************

Private Function fun_ShowReport( ) As Boolean

Dim obj_Report As New CrystalDecision s.CrystalReport s.Engine.Report Document

Dim frm_Viewer As New frmViewReport

Dim crTableLogonInf o As TableLogOnInfo

Dim crConnectionInf o As ConnectionInfo

Dim crTable As CrystalDecision s.CrystalReport s.Engine.Table

Try

crTableLogonInf o = New TableLogOnInfo

crConnectionInf o = New ConnectionInfo

crConnectionInf o.DatabaseName = g_str_Database

crConnectionInf o.ServerName = g_str_Server

crConnectionInf o.UserID = g_str_Username

crConnectionInf o.Password = g_str_Password

crTableLogonInf o.ConnectionInf o = crConnectionInf o

With obj_Report

..Load(m_str_Re portFilename)

For Each crTable In .Database.Table s

crTable.ApplyLo gOnInfo(crTable LogonInfo)

Next

..SetParameterV alue("@FromDate ", txt_StartDate.S etDBValue)

..SetParameterV alue("@ToDate", txt_EndDate.Set DBValue)

If m_int_ReportNam e <> ReportName.Repo rt_UserFeedback Then

..SetParameterV alue("@Hospital ID", fun_SetNull(cls PharmacyClass.R eportHospital))

..SetParameterV alue("@WardID", fun_SetNull(cls PharmacyClass.R eportWard))

End If

Select Case m_int_ReportNam e

Case ReportName.Repo rt_Intervention

..SetParameterV alue("@PatientI D", 0)

..SetParameterV alue("@Pharmaci stID", fun_SetNull(cls PharmacyClass.R eportPharmacist ))

Dim int_Interventio nComplete As Object

Dim sys_NullValue As System.DBNull

Select Case cbo_Filter.Sele ctedIndex

Case 0

int_Interventio nComplete = sys_NullValue

Case 1

int_Interventio nComplete = 0

Case 2

int_Interventio nComplete = 1

End Select

..SetParameterV alue("@Interven tionComplete", int_Interventio nComplete)

..SetParameterV alue("@int_Mode ", 1)

Case ReportName.Repo rt_MonthlyActiv ity

..SetParameterV alue("@Pharmaci stID", fun_SetNull(cls PharmacyClass.R eportPharmacist ))

End Select

..SetDatabaseLo gon(g_str_Usern ame, g_str_Password, g_str_Server, g_str_Database)

End With

If ysd_Destination .StringValue = "Screen" Then

frm_SuccessMess age.fun_OpenFor m _

("Printing to screen - Please wait....")

frm_Viewer.crv_ ReportViewer.Re portSource = obj_Report

frm_Viewer.Show Dialog()

Else

frm_SuccessMess age.fun_OpenFor m _

("Printing - Please wait....")

obj_Report.Prin tToPrinter(1, True, 0, 0)

End If

Return True

Catch ex As Exception

ErrorMessage("U nable to show report " & _

ControlChars.Cr Lf & "Error Message: " & ex.Message.ToSt ring)

Return False

Finally

obj_Report = Nothing

frm_Viewer = Nothing

End Try

End Function


Nov 20 '05 #1
3 9232
this is C# and its setting the datasource for the subreports but the logic
is almost identical

private void SetReportDataSo urce(ReportDocu ment _Report, DataSet _ds) {
_Report.SetData Source(_ds) ;

for (int i = 0; i < _Report.ReportD efinition.Repor tObjects.Count; i++) {
ReportObject CurrentObject = _Report.ReportD efinition.Repor tObjects[i];

if(CurrentObjec t.Kind ==
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject) {
ReportDocument SubReport =
_Report.OpenSub report(((Subrep ortObject)Curre ntObject).Subre portName);
SetReportDataSo urce(SubReport, _ds) ;
}
}
}

so in vb.net the basic logic is ...
private sub SetReportLogon( ByVal Report as ReportDocument)
int i

'set logon info

for i = 0 to Report.ReportDe finition.Report Objects.Count - 1
dim CurrentObject as ReportObject=
Report.ReportDe finition.Report Objects[i]

if CurrentObject.K ind =
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject
dim SubReport as ReportDocument =
_Report.OpenSub report(directca st(CurrentObjec t,subreportobje ct).SubreportNa m
e)
SetReportDataSo urce(SubReport)
end if
next
end sub

Cheers,

Greg
Nov 20 '05 #2
Thanks greg, I know this wasn't for me. But greatly helped!

-CJ

"Greg Young" <gr********@pla netbeach.com> wrote in message
news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
this is C# and its setting the datasource for the subreports but the logic
is almost identical

private void SetReportDataSo urce(ReportDocu ment _Report, DataSet _ds) {
_Report.SetData Source(_ds) ;

for (int i = 0; i < _Report.ReportD efinition.Repor tObjects.Count; i++) { ReportObject CurrentObject = _Report.ReportD efinition.Repor tObjects[i];
if(CurrentObjec t.Kind ==
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject) {
ReportDocument SubReport =
_Report.OpenSub report(((Subrep ortObject)Curre ntObject).Subre portName);
SetReportDataSo urce(SubReport, _ds) ;
}
}
}

so in vb.net the basic logic is ...
private sub SetReportLogon( ByVal Report as ReportDocument)
int i

'set logon info

for i = 0 to Report.ReportDe finition.Report Objects.Count - 1
dim CurrentObject as ReportObject=
Report.ReportDe finition.Report Objects[i]

if CurrentObject.K ind =
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject
dim SubReport as ReportDocument =
_Report.OpenSub report(directca st(CurrentObjec t,subreportobje ct).SubreportNa m e)
SetReportDataSo urce(SubReport)
end if
next
end sub

Cheers,

Greg

Nov 20 '05 #3
glad I could help.
"CJ Taylor" <[cege] at [tavayn] dit commmmm> wrote in message
news:Oi******** ******@TK2MSFTN GP12.phx.gbl...
Thanks greg, I know this wasn't for me. But greatly helped!

-CJ

"Greg Young" <gr********@pla netbeach.com> wrote in message
news:Ob******** ******@TK2MSFTN GP11.phx.gbl...
this is C# and its setting the datasource for the subreports but the logic is almost identical

private void SetReportDataSo urce(ReportDocu ment _Report, DataSet _ds) { _Report.SetData Source(_ds) ;

for (int i = 0; i < _Report.ReportD efinition.Repor tObjects.Count; i++)
{
ReportObject CurrentObject =

_Report.ReportD efinition.Repor tObjects[i];

if(CurrentObjec t.Kind ==
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject) {
ReportDocument SubReport =
_Report.OpenSub report(((Subrep ortObject)Curre ntObject).Subre portName);
SetReportDataSo urce(SubReport, _ds) ;
}
}
}

so in vb.net the basic logic is ...
private sub SetReportLogon( ByVal Report as ReportDocument)
int i

'set logon info

for i = 0 to Report.ReportDe finition.Report Objects.Count - 1
dim CurrentObject as ReportObject=
Report.ReportDe finition.Report Objects[i]

if CurrentObject.K ind =
CrystalDecision s.Shared.Report ObjectKind.Subr eportObject
dim SubReport as ReportDocument =

_Report.OpenSub report(directca st(CurrentObjec t,subreportobje ct).SubreportNa m e)
SetReportDataSo urce(SubReport)
end if
next
end sub

Cheers,

Greg


Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2287
by: Sean G. | last post by:
Howdy, I have a series of crystal reports, some have subreports, that I need to put together in one file on one click form the user. So put I imported the separate rpt files as subreports into one big master report. Now I know crystal doesn't support subreports in subreports. If the lowest level subreports existed as rpt files, I could import them into the master report and use grouping to make it look like the subreports in the...
1
3460
by: Mithun Verma | last post by:
Hello All, I have a Windows application that uses Crystal Reports 9 (bundled Version) developed using VS.NET 2003 on a windows server 2003 m/c. The application has to be deployed on the client machine that has Windows XP installed. Before deploying we make sure that .NET framework 1.1 is installed on the XP machine. In the setup project, for support for Crystal Reports, we have added the following merge modules: 1)Crystal_Managed2003.msm...
1
334
by: Michael O'Donnell | last post by:
Hi All Am having major problem with crystal reports...Have designed my report no problem, its when I try to run and display ther report that I am getting a "Login Failed" message. At first I thought it might have to do with the regristration key, but that ok, when I right click on Servers in the server explorer and then expand the Crystal Server, there is a red x beside the Crystal Enterprise. When I click on log in, I am asked for a
0
2389
by: KartoffelKiffer | last post by:
Hello, i have to do a little Crystal Report task, where i need help. I have a mainreport in which are some subreports. The size of the subreports can vary so the subreport which could be bigger than before overlap the other subreports. Is it psossible that the subreports are fixed an when they need more place the size could be bigger ? I hope my english is ok, so you can help me :?
4
1050
by: Stig | last post by:
I'm having two tables with no relation and I want to list them both in one report. How can I do this. I have tried to use sub report, but cant get it to work? can someone please help me. If I just create an subreport with one static text object it will not even then show at runetime.
3
9912
by: LataChavan | last post by:
I have tried to look for a solution to the problem of sending parameters to stored procedures through crystal report. Following is the code: Now what happens is that if i do not apply the logon information the crystal reports works fine by accepting the parameter values and giving the Database Logon prompt when we run the report. But I would like to give the logon information at runtime. If I give the info at runtime the "stored procedure"...
0
1518
by: brett | last post by:
Hi, I need to build a pdf report by using Crystal report which including several subreport. The problem is that the primary page orientation is portrait and some subreports' orientation is landscape. I cannot find a way to set subreports' orientation in Crystal report. Is there an solution for this problem? Thanks in advance!
2
2869
by: Franck | last post by:
Ok i have a problem. What do i need to change to make crystal show subreport within subreports ? So i have 3 layer The MainReport Multiple SubReport Attached in the MainReport Multiple SubSubReport Attached in the SubReports Showing the SubReport itself by bypassing the MainReport the SubSubREport are showing
3
3816
by: Miro | last post by:
Hi, Just wondering what a good book is on visual studios 2008 ( or 2005 if no 2008 ) that teaches you how to properly use crystal reports with it. Or im assuming that as long as I can create a dataset and link it to a reportviewer than any Crystal Report book will do. I use vb.net but im assuming most books would show you vb and c
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8855
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7708
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2320
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.