Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Session Variable Values

Status
Not open for further replies.

ami7

Programmer
Oct 3, 2002
48
GB
Hi all,

Can anyone tell me how to pass a session variable value from my .aspx page to report.

i have created a crystalreport.rpt file based on a dataset.
Works fine but i want to display few other values in my report in my details section which is already avble in session variables in my form.

Is there any way to achieve this..??

Pls help.

Thanks in advance,
ami.
 
pass it as a field added to your dataset. That's what I do.

hth Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
Hi,

I can't reference that fiels as part of a dataset.
When the form is opened the user will enter a value in a text box .it is from a different table.
But i have that value being stored in a session variable.

Just wanted to display this in my report.

any tips on this..?

Thanks for ur help.
ami.
 
here is what I do:

I have my dataset (xsd file) and I added a field to it:

field iPageStart as an int

then after I filled the DataSet with my data I do this:


for(int j=0;j<ds.Tables[&quot;vwDirectory&quot;].Rows.Count;j++)
{
DataRow dr = ds.Tables[&quot;vwDirectory&quot;].Rows[j];
dr[&quot;iPageStart&quot;] = iPage;
}

ds.Tables[&quot;vwDirectory&quot;].AcceptChanges();
rptDirectory cr = new rptDirectory(); //my report class


iPage is a value that the user return to me through an Input script box:

&quot;What page number would you like the report to start with?&quot;

in the report I have a brand new field called iPageStart that I can use in a formula to print the page number!

hth Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
hi daren,

You have mentd that:

in the report I have a brand new field called iPageStart that I can use in a formula to print the page number!

How to create a brand new field in report.
Also Can u give me a simple example of using a formula.

Thanks for ur great help.

ami.
 
if you are using VS.NET and using the Strongly Type DataSet:

File - Add New Item... - DataSet Scheam (xsd file)
You will be able to see all the fields take from your table/view or StoredProcedure
At the end of this (table view) you will be able to add additional fields, and I did add iPageStart, remembering that when I fill the DataSet witht he Data I will have to manually add the information for that field (like I showed you above in previous post)

are you following me so far? Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
ofcourse am following you.

LEt me explain you my exact requirement.

I have a dataset which is populated by calling a web service .The web service calls a procedure which inserts data into a table.(eg: emp)
Also i display the same in a datagrid.

Wat am trying to achieve is to display the same datagrid values as a report with some addl. fields from my form.

My code:
--------
With New EIEWebService()
Dim dataTemp As DataSet = CType(dataGrid, DataSet)
.InsertEmp(&quot;N&quot;, dataClient.Users(0).Username, Request.UserHostAddress, dataClient.Users(0).SiteNo, sSRFRequired, dataTemp)

' Put the results back in the local data set.
dataGrid.Clear()
dataGrid.Merge(dataTemp)

' Refresh session variable with modified values.
Session(&quot;GridData&quot;) = dataGrid
End With

Now in my dataset(dataset1.xsd) i have few fields called
empno, ename, sal
Wat i want is to display values of another tables info.
like deptname,location which is not part of my dataset.
These values are in the form. I thought i can assign them to a session variable and refer them in my report.

Wat i want is to display these values in my report.

Ques:
1) If i can add it to my dataset and refer it in my form then that would be great..
As u mentioned above if i add a field in my dataset then how can i refer them in my code before populating the data?

2) Is there any way to display the session variable value in report.??


Please guide me on this.

Hope it is clear.

Thanks,
ami.




 
1) yes you can. You should be able to refere to the dataset from the Databinding property on the property page.

2)No, at least not directly. You need to pass it in or as a field member or as a report parameter (which I am not to sure I know how)

hth Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
Hi,

Thanks for that info.
I have solved the problem by passing parameters to report from forms and then accessing them by creating parameters in the report.
It is very simple..

anyways thanks for your help.

One more ques:

I am trying to print the same to a pdf file.
it was working fine but after adding parameters to the report it is asking to pass values to parameters from wherever am calling it.

am trying this but says &quot;object ref not set to an instance of the object&quot;
I don't know if this is the right way of doing it.


Dim rReport As myReport = New myReport()
Dim GridData As DataSet = CType(Session(&quot;GridData&quot;), DataSet)

rReport.Parameter_empno.CurrentValues.Add(dataclient.Users(0).empno)
(gives error in the above line)

Dim sFileName As String = &quot;c:\rReport.pdf&quot;
rReport.SetDataSource(GridData)
Dim diskOpts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions()
rReport.ExportOptions.ExportDestinationType = CrystalDecisions.[Shared].ExportDestinationType.DiskFile
rReport.ExportOptions.ExportFormatType = CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat
diskOpts.DiskFileName = sFileName
rReport.ExportOptions.DestinationOptions = diskOpts

rReport.Export()
Response.Redirect(sFileName)


thanks,
ami.
 
this is what I do in c#:

strName = @&quot;C:\Reports\&quot; + Session.SessionID.ToString() + &quot;.pdf&quot;;
crDestination = new DiskFileDestinationOptions();
crDestination.DiskFileName = strName;
crExportOpt = cr.ExportOptions;
cr.ExportOptions.DestinationOptions = crDestination;
cr.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
cr.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

cr.Export();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = &quot;application/pdf&quot;;
Response.WriteFile(strName);
Response.Flush();
Response.Close();


hth Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
But your r not passing any parameter value..?

Without passing that value it works for me but the report which i am trying to print to file has few paramters..

that's were the problem is..

btw how to get rid of this &quot;powered by cystal&quot; logo
any tips.
thanks.

ami
 
Each customers that want's online reporting needs to buy a licence from Crystal Decisions. With the licence you are able to put the key in one of the properties of the Crystal Report class and &quot;get rid of&quot; the Powered by Crystal =)

As for printing a report with parameters, I have never done it. Sorry.

Good Luck! Daren J. Lahey
Just another computer guy...
If you are unsure of forum etiquette check here FAQ796-2540
 
Thanks for your great help.
It was very helpful.

Rgds,
ami.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top