Monday, July 20, 2009

Passing parameters programmatically to Crystal report

It is very easy to pass the parameters in Crystal reports editing the crystal reports ( just by adding the required parameters on the report and making "EnableParameterprompt = "True" " in the properties of the crystal report viewer. , but it has several drawbacks, like the parameters do not get added to the report automatically, we can not really modify the interface of parameter prompt and so on. 

Today we are discussing about the parameter passing to crystal reports programmatically.  
In .aspx page, drag the control to ask for the parameters and drag the control for Crystal report viewer as follows:
<table>
<tr><td style="vertical-align: top; text-align: left; height: 21px;"><asp:Label ID="lbl1" runat="server" Text="Choose the semester" style="vertical-align: top; text-align: left" />td>
<td style="height: 21px; vertical-align: top; text-align: left;"><asp:DropDownlist ID="drpSemester" runat="server" AppendDataBoundItems="True" DataSourceID="SqlDataSource1" DataTextField="Semester" DataValueField="Semester"/>td>
tr><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="" SelectCommand="SELECT [Semester] FROM [SemesterInformation] ORDER BY [BeginDate], [EndDate]">
    asp:SqlDataSource>
<tr><td><asp:Button ID="cmdGenreport" runat="server" Text="Generate Report" />td>tr>
table>
      <CR:CrystalReportViewer ID="myCrystalReportViewer" runat="server" AutoDataBind="True"
         Height="1039px" ReportSourceID="CrystalReportSource1" Width="901px" style="position: absolute" EnableDatabaseLogonPrompt="false" EnableParameterPrompt="false" />
   
Design a report with parameters. To add a parameter in a report, you have to go to the “Database expert”, in the command edit box, you will see “parameter list” at the right hand side of the box, create a new parameter there and include that in your query. Add the following code in the load event of your page:
  Dim CRreport As New ReportDocument
        If Session("report1") IsNot Nothing Then
            CRreport = Session("report1")
            myCrystalReportViewer.ReportSource = CRreport
        End If
In the click event if the “cmdgenerateReport” Button add the following code:
  Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()
        Dim strReportName As String = ""
        Dim cryRep As New ReportDocument
        myConnectionInfo.DatabaseName = "Databasename"
        myConnectionInfo.ServerName = "Servername"
        myConnectionInfo.UserID = "Username"
        myConnectionInfo.Password = "password"
        myConnectionInfo.Type = ConnectionInfoType.SQL
        report.Load(Server.MapPath("~/myreport1.rpt"))
        SetDBLogonForReport(myConnectionInfo, report)
        'Load Session variables with values from web-controls
        Session("Semester") = drpSemester.SelectedValue.ToString()
        'Load all parameter fields associated with the report into "fields" object
        Dim fields As ParameterFields
        fields = New CrystalDecisions.Shared.ParameterFields()
        fields = report.ParameterFields
        For Each field As ParameterField In fields
            report.SetParameterValue(field.Name, Session(field.Name))
        Next
        myCrystalReportViewer.ReportSource = report
        Session("report1") = report
The setDBlogonForreport is as follows:
  Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)
        Dim myTables As Tables = myReportDocument.Database.Tables
        Dim myTableLogonInfos As TableLogOnInfos = myCrystalReportViewer.LogOnInfo
        Dim myTablelogonInfo As TableLogOnInfo
        For Each myTable As Table In myTables
            myTablelogonInfo = myTable.LogOnInfo
            myTablelogonInfo.ConnectionInfo = myConnectionInfo
            myTable.ApplyLogOnInfo(myTablelogonInfo)
        Next
    End Sub
To manage the proper navigation of the report include the following code in the .vb page:
  Protected Sub myCrystalReportViewer_Navigate(ByVal source As Object, ByVal e As CrystalDecisions.Web.NavigateEventArgs) Handles myCrystalReportViewer.Navigate
        report.FileName = Server.MapPath("~/myreport1.rpt")
        Dim fields As ParameterFields
        fields = New CrystalDecisions.Shared.ParameterFields()
        fields = report.ParameterFields
    End Sub
Add the following code at the unload event of the page:
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
        myCrystalReportViewer.Dispose()
        GC.Collect()
    End Sub
In this way, you can pass as many parameters as you need to crystal reports.
Please write comment below if you have any kinds of questions/suggestions. 

Saturday, July 11, 2009

NepaliGal and NepaliGuy Comic Strip

Its just an initial try.. :-)... Please click on the comic strip below to read it properly..

Tuesday, June 23, 2009

Deploying web-applications which use Crystal-Reports

Creating an installer is very much necessary to distribute the reporting applications being used in the web-application. In this section we are discussing how to deploy the web-application(which is using crystal reports) using Microsoft Visual Studio 2005.
1. Create a setup file

Go to File> New Project >Setup and Deployment > Web setup project As shown in the figure below. Specify the name of the setup file and click on "OK"

2. There should be a bin folder inside "Web Application Folder" . Add references used in your project including the references used for Crystal report in the folder. You can do so by right clicking the "bin" folder and going to Add > Assembly

3. Now, you need to add all the files of your website to the setup file. Right click on the "Web Application Folder" in the file system column or the name of the setup file on the solutions explorer; go to Add > File and add all the files of your website.

4. Besides files and references, the special kinds of files called merge modules also need to be added to the setup file. Merge modules help us to determine the run time requirements of crystal reports such as formats of the reports. Mainly, there are three kinds of merge modules, Managed.msm, Database_Access_enu.msm and Regwiz.msm. You can download the merge modules for visual studio .net from here.

5. You can add the merge modules by right clicking on your setup file at the solution explorer and go to Add > Merge Modules.

6. After adding all three merge modules, you need to specify your licence of crystal report as well. You can get the license key by registering for Crystal reports. To register for Crystal reports, go to the crystal report menu of your crystal report application, select "Register/Change Address" and follow the wizard. You will get a licence key in your email after the successful registration.

7. Once you get the license key, right click on the Regwiz.msm merge module file in the solution explorer, go to properties; Click on Merge module properties and paste the License key there as shown in the figure below:

8. The addition of all the files are completed. Now, you have to specify the prerequisites of the web application. Right click your setup file in the solution explorer and go to properties. Click on the "Prerequisites" command button. Check on the top three check boxes if they are unchecked. Choose " Download prerequisites from same location as my application" radio button below. And then click on OK.

Your web-application setup file ready now. Run the setup file on the server. If crystal report is not installed on your server, this setup file will install that first because of the prerequisites you specified. It is better to remove the previously installed crystal report ( if it is installed already), from the control panel of the server and start running the set up file.

Please add a line here if you have any questions/confusions regarding this post and regarding the deployment of the web-application.

Tuesday, April 21, 2009

Some Grad students' jokes

You know you're a grad student when...


  • you can identify universities by their internet domains.
  • you are constantly looking for a thesis in novels.
  • you have difficulty reading anything that doesn't have footnotes.
  • you understand jokes about Foucault.
  • the concept of free time scares you.
  • you consider caffeine to be a major food group.
  • you've ever brought books with you on vacation and actually studied.
  • Saturday nights spent studying no longer seem weird.
  • the professor doesn't show up to class and you discuss the readings anyway.
  • you've ever travelled across two state lines specifically to go to a library.
  • you appreciate the fact that you get to choose which twenty hours out of the day you have to work.
  • you still feel guilty about giving students low grades (you'll get over it).
  • you can read course books and cook at the same time.
  • you schedule events for academic vacations so your friends can come.
  • you hope it snows during spring break so you can get more studying in.
  • you've ever worn out a library card.
  • you find taking notes in a park relaxing.
  • you find yourself citing sources in conversation.
  • you've ever sent a personal letter with footnotes.
  • you can analyze the significance of appliances you cannot operate.
  • your office is better decorated than your apartment.
  • you have ever, as a folklore project, attempted to track the progress of your own joke across the Internet.
  • you are startled to meet people who neither need nor want to read.
  • you have ever brought a scholarly article to a bar.
  • you rate coffee shops by the availability of outlets for your laptop.
  • everything reminds you of something in your discipline.
  • you have ever discussed academic matters at a sporting event.
  • you have ever spent more than $50 on photocopying while researching a single paper.
  • there is a microfilm reader in the library that you consider "yours."
  • you actually have a preference between microfilm and microfiche.
  • you can tell the time of day by looking at the traffic flow at the library.
  • you look forward to summers because you're more productive without the distraction of classes.
  • you regard ibuprofen as a vitamin.
  • you consider all papers to be works in progress.
  • professors don't really care when you turn in work anymore.
  • you find the bibliographies of books more interesting than the actual text.
  • you have given up trying to keep your books organized and are now just trying to keep them all in the same general area.
  • you have accepted guilt as an inherent feature of relaxation.
  • you find yourself explaining to children that you are in "20th grade".
  • you start refering to stories like "Snow White et al."
  • you often wonder how long you can live on pasta without getting scurvy.
  • you look forward to taking some time off to do laundry.
  • you have more photocopy cards than credit cards.
  • you wonder if APA style allows you to cite talking to yourself as "personal communication".
  • you have a favourite flavour of instant noodle.
( Source: http://www.chat.carleton.ca/~jnoakes/grad.html)

Monday, April 20, 2009

Hi,

This is the discussion board for .NET. Please post here if you have got any problem in .NET, we'll discuss about the problem. If you find the solution to the problem, then post the solution too, so that it will be easier for others, if they get the same problem.

Thank you,
Technobloggersnp

Wednesday, April 15, 2009

ASP .NET - Development Server(Local Host) - Page Not found problem

I typically, do not use Microsoft Visual Studio 2005 from my laptop, but today I had to. I designed a simple page and tried to run that, but it said " Page can not be displayed, check your Internet Connection.. blah blah" . I searched over the internet regarding this error but most of the solutions were regarding IIS which I was not using at that time. 

After some time I found that  the problem is because of IPV6 supports of ASP.NET Development Server. To disable IPV6 so that ASP.NET Development Server runs, we can do as below.

1. Go to c:\Windows\System32\Drivers\etc\.

2. Edit file hosts. Put a ‘#’ before the rows “::1 localhost”.

3. Save it.

If you can not save the file and get some permission errors, follow the following steps:

1.  Run cmd as Administrator ( in Windows Vista) first. 

2. Go to c:\Windows\System32\Drivers\etc\ from command prompt. 

3. Type "Edit hosts" there

4. Put a ‘#’ before the rows “::1 localhost” and save it.

After saving the file go to your visual studio, compile the website again. It will run. 


Welcome

Welcome to our blog. 

Today, we are in the world of Information technology. People are getting more obsessed to the technological stuffs like websites, blogs and different electronic gadgets. We have started this blog to help those people who like to do programming and read about the electronic designs. 

Here, we are going to post the issues which we have faced and post the solutions to those issues which we implemented. You can get many technical blogs in the blogosphere, however we want to do something different.  In our blog, we discuss about programming issues, Electronic issues and other issues as well. We have tried to make our blog versatile, so that you can get much more information.

Please keep visiting our blog and send us your wonderful suggestions. 

Thank you,
Techno-Bloggers
 

Techno-News

Click here to read the current news in technical world.
Pomegranatephone Isn't it cool ?
Google Phone
Twitting heart beat