473,789 Members | 2,957 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting Crystal Report parameters via a form problem

Hi,

I'm new to ASP.Net and Crystal but I've been playing with some samples
and have run into a problem.

If I put all my code into the Page_Init sub of a single form and run
that form, the Crystal report runs fine.

Now i am trying to create another web form where I can input
parameters, hit submit and have those parameters passed to the second
form to diplay the Report. Perhaps I don't understand how to pass them
from a web form. I created a sub routine in my 'Reports' form and
moved my code from the Page_Init sub to this sub. Then I try to call
the sub from my Submit action in my parameter entry form. The code
fails when the sub trys to execute the following:

CrystalReportVi ewer1.ReportSou rce = myReport

It fails with 'Object reference not set to an instance of an object'.

Here is the code that works if it is in the Page_Init sub:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.Shared

Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents CrystalReportVi ewer1 As
CrystalDecision s.Web.CrystalRe portViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
Dim myReport As New ReportDocument( )
Dim crParameterFiel dDefinitions As ParameterFieldD efinitions
Dim crParameterFiel dDefinition As ParameterFieldD efinition
Dim crParameterValu es As ParameterValues
Dim crParameterDisc reteValue As ParameterDiscre teValue
Dim crParameterFiel dValues As ParameterValues

'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
myReport.Load(" c:\inetpub\wwwr oot\web_viewer_ basic2\imp.rpt" )
crParameterFiel dDefinitions =
myReport.DataDe finition.Parame terFields
crParameterFiel dDefinition =
crParameterFiel dDefinitions.It em("Street Number")
crParameterValu es = crParameterFiel dDefinition.Cur rentValues
crParameterDisc reteValue = New ParameterDiscre teValue()
crParameterDisc reteValue.Value = "*400*" '1st current value
crParameterValu es.Add(crParame terDiscreteValu e)

**Snip, add more paramters. The values are hardcoded right
now.***

Dim crtableLogoninf os As New TableLogOnInfos ()
Dim crtableLogoninf o As New TableLogOnInfo( )
Dim crConnectionInf o As New ConnectionInfo( )
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter

With crConnectionInf o
.ServerName = "DATABASE"
.DatabaseName = "dev"
.UserID = "userid"
.Password = password"
End With

**Snip, Loop through and login to all the tables**

CrystalReportVi ewer1.ReportSou rce = myReport
CrystalReportVi ewer1.DataBind( )

End Sub

Can anyone give me some pointers on how to submit the parameters from
another form and pass them through to this form? I also suspect that
my declaration may be in the wrong place in the code.

Thanks,

Chris
Nov 17 '05 #1
2 2722
Actually, I solved the problem myself. First, I just used the
Response.Redire ct method and passed the variables to the viewer form.
It worked but I wanted it to open in a new browser window so I used
client-side Javascript to do it.

All I need to do now is figure out why my new window is not taking the
focus.

cf*****@hotmail .com (Chris) wrote in message news:<d9******* *************** ****@posting.go ogle.com>...
Hi,

I'm new to ASP.Net and Crystal but I've been playing with some samples
and have run into a problem.

If I put all my code into the Page_Init sub of a single form and run
that form, the Crystal report runs fine.

Now i am trying to create another web form where I can input
parameters, hit submit and have those parameters passed to the second
form to diplay the Report. Perhaps I don't understand how to pass them
from a web form. I created a sub routine in my 'Reports' form and
moved my code from the Page_Init sub to this sub. Then I try to call
the sub from my Submit action in my parameter entry form. The code
fails when the sub trys to execute the following:

CrystalReportVi ewer1.ReportSou rce = myReport

It fails with 'Object reference not set to an instance of an object'.

Here is the code that works if it is in the Page_Init sub:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.Shared

Public Class WebForm1
Inherits System.Web.UI.P age
Protected WithEvents CrystalReportVi ewer1 As
CrystalDecision s.Web.CrystalRe portViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
Dim myReport As New ReportDocument( )
Dim crParameterFiel dDefinitions As ParameterFieldD efinitions
Dim crParameterFiel dDefinition As ParameterFieldD efinition
Dim crParameterValu es As ParameterValues
Dim crParameterDisc reteValue As ParameterDiscre teValue
Dim crParameterFiel dValues As ParameterValues

'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeCompo nent()
myReport.Load(" c:\inetpub\wwwr oot\web_viewer_ basic2\imp.rpt" )
crParameterFiel dDefinitions =
myReport.DataDe finition.Parame terFields
crParameterFiel dDefinition =
crParameterFiel dDefinitions.It em("Street Number")
crParameterValu es = crParameterFiel dDefinition.Cur rentValues
crParameterDisc reteValue = New ParameterDiscre teValue()
crParameterDisc reteValue.Value = "*400*" '1st current value
crParameterValu es.Add(crParame terDiscreteValu e)

**Snip, add more paramters. The values are hardcoded right
now.***

Dim crtableLogoninf os As New TableLogOnInfos ()
Dim crtableLogoninf o As New TableLogOnInfo( )
Dim crConnectionInf o As New ConnectionInfo( )
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter

With crConnectionInf o
.ServerName = "DATABASE"
.DatabaseName = "dev"
.UserID = "userid"
.Password = password"
End With

**Snip, Loop through and login to all the tables**

CrystalReportVi ewer1.ReportSou rce = myReport
CrystalReportVi ewer1.DataBind( )

End Sub

Can anyone give me some pointers on how to submit the parameters from
another form and pass them through to this form? I also suspect that
my declaration may be in the wrong place in the code.

Thanks,

Chris

Nov 17 '05 #2
Ok, so I set the new window's focus() with Javascript. The new window
still goes to the back with the parent having focus until the actual
page loads (a crystal report). Then the new page gets the focus. I
realize that the parent is submiting back to itself which is why it is
keeping the focus on submit. Is there any way to have the parent just
lose focus the whole time?

cf*****@hotmail .com (Chris) wrote in message news:<d9******* *************** ****@posting.go ogle.com>...

**snip**
Nov 17 '05 #3

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

Similar topics

1
3636
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to make a report( VS.NET, C#, Web Form) with 3 parts and with data from three tables: 1st part: all the field values form table1 coresponding to an Id (Id
0
4899
by: Craig Faulkner | last post by:
I have been fighting through my first crystal report in VS2003.NET and have made some headway. Here is what I've done: 1. Created a crystal report in VS2003 from a SQL stored procedure with parameters through the GUI. 2. Finally got past the logon failure error to display the report using the viewer. I assume that default parameters are being used since it does display some data and the SP won't run without being passed some values.
0
2074
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the data into a comboBox. One thing I noticed, however, is that this method shows me both the parameters used by the main report and parameters used by the sub-report(s).
4
2500
by: touf | last post by:
hi, I'm using Crystal reports to generate a simple report in a VB.net windows application, I've defined all my stuffs (accessMDB,query, 2 parameters) in the report design, and it's working fine, when a report is opened it prompts me to input the parameters values . But, in order to incorporate this report to my application, I have 3 quetions: 1- How can I send the parameters from my form directly (so there will be no prompt)? 2- How can...
12
10415
by: Bill Nguyen | last post by:
What's the VB syntax to run the CR report using the following SP? I use CrystalreportViewer and ReportDocument. Thanks Bill Here's the SP in SQLserver 2K: CREATE proc mysp_ReportSubmission @salesdate as varchar(20),
0
1290
by: Alison Givens | last post by:
Hi all, I have been suffering with this problem for weeks now. I tried several newsgroups, but nobody can tell me how to solve this problem. The problem: I have a webform that shows a Crystal Report. In the page_init I export the report to a pdf. When I hit the printbutton, the PDF shows. When I close the form, the PDF is deleted from the server. So far, so good. This works for all reports, exept for reports with parameters. The...
2
2927
by: mounilkadakia | last post by:
I have a CrystalReportViewer(crv) on my form. I also have a dataset (dtsReportData) populated with the required data and i have a ReportDocument (rdReport) object. The data source for the crystal report (CR 11) is a stored procedure. This is what i am doing:- rdReport.Load("ReportLocation"); //ReportLocation is the file path. rdReport.SetDataSource(dtsReportData); crv.ReportSource = rdReport;
7
6721
by: Jlo | last post by:
Hi, I have a c# winforms application. When I call the report file, it shows me all the records in the table. How can I make it to call only a particular range. i have the following code Viewer1.ReportSource = Application.StartupPath + "//Label.rpt"; How can I assign it a dataset which have the data of a particular range.
1
11045
by: Rodo | last post by:
Hi all, I'm trying to generate a simple crystal report without a database. Several people mention the use of a dataset. Someone mention in a msdn forum that I could use the SetParameterValue to easily fill the fields in a simple report. So. I looked at datasets and I think I'll try this way first. I'm pretty new and I still don't understand much of this stuff. So. here is what I did . and it is not working :-(. 1.-create new windows...
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10139
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,...
1
7529
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...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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
3
2909
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.