473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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:

CrystalReportViewer1.ReportSource = 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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
Dim myReport As New ReportDocument()
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldValues As ParameterValues

'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
myReport.Load("c:\inetpub\wwwroot\web_viewer_basic 2\imp.rpt")
crParameterFieldDefinitions =
myReport.DataDefinition.ParameterFields
crParameterFieldDefinition =
crParameterFieldDefinitions.Item("Street Number")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = "*400*" '1st current value
crParameterValues.Add(crParameterDiscreteValue)

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

Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter

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

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

CrystalReportViewer1.ReportSource = myReport
CrystalReportViewer1.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 2704
Actually, I solved the problem myself. First, I just used the
Response.Redirect 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.google. 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:

CrystalReportViewer1.ReportSource = 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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
Dim myReport As New ReportDocument()
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldValues As ParameterValues

'CODEGEN: This method call is required by the Web Form
Designer
'Do not modify it using the code editor.
InitializeComponent()
myReport.Load("c:\inetpub\wwwroot\web_viewer_basic 2\imp.rpt")
crParameterFieldDefinitions =
myReport.DataDefinition.ParameterFields
crParameterFieldDefinition =
crParameterFieldDefinitions.Item("Street Number")
crParameterValues = crParameterFieldDefinition.CurrentValues
crParameterDiscreteValue = New ParameterDiscreteValue()
crParameterDiscreteValue.Value = "*400*" '1st current value
crParameterValues.Add(crParameterDiscreteValue)

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

Dim crtableLogoninfos As New TableLogOnInfos()
Dim crtableLogoninfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter

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

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

CrystalReportViewer1.ReportSource = myReport
CrystalReportViewer1.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.google. com>...

**snip**
Nov 17 '05 #3

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

Similar topics

1
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...
0
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...
0
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...
4
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,...
12
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...
0
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...
2
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...
7
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.