|
Journal_Rep.asp
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Journal_Rep.aspx.cs" Inherits="Journal_Rep" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="height: 477px">
<table class="style1">
<tr>
<td style="text-align: left">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="width: 213px; text-align: right;">
Date From :</td>
<td style="color: #FF0000; width: 10px;">
</td>
<td style="text-align: left">
<asp:TextBox ID="DateFrom" runat="server" CssClass="textbox"
Height="22px" Width="131px"></asp:TextBox>
<asp:CalendarExtender ID="DateFrom_CalendarExtender" runat="server"
Enabled="True" TargetControlID="DateFrom">
</asp:CalendarExtender>
<asp:RangeValidator ID="RangeValidator16" runat="server"
ControlToValidate="DateFrom" ErrorMessage="Invalid Date Format"
ForeColor="Red" MaximumValue="1/1/2050" MinimumValue="1/1/1940"
Type="Date" Display="Dynamic"></asp:RangeValidator>
</td>
</tr>
<tr>
<td style="text-align: right">
To :</td>
<td>
</td>
<td>
<asp:TextBox ID="DateTo" runat="server" CssClass="textbox"
Height="22px" Width="131px"></asp:TextBox>
<asp:CalendarExtender ID="DateTo_CalendarExtender" runat="server"
Enabled="True" TargetControlID="DateTo">
</asp:CalendarExtender>
<asp:RangeValidator ID="RangeValidator26" runat="server"
ControlToValidate="DateTo" ErrorMessage="Invalid Date Format"
ForeColor="Red" MaximumValue="1/1/2050" MinimumValue="1/1/1940"
Type="Date" Display="Dynamic"></asp:RangeValidator>
<asp:CompareValidator ID="CompareValidator3" runat="server"
ControlToCompare="DateFrom" ControlToValidate="DateTo" Display="Dynamic"
ErrorMessage="Date must be Greater Than Date from or Equal"
Operator="GreaterThanEqual" style="color: #F80000" Type="Date"></asp:CompareValidator>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
<asp:Button ID="BtnRep" runat="server" Text="Ok" class="button"
Height="26px" onclick="BtnLogin_Click" Width="135px" CssClass="Mybutton" />
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="text-align: right">
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</asp:Content>
--------------------------------------------
Journal_Rep.asp.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using CrystalDecisions.CrystalReports.Engine;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Journal_Rep : System.Web.UI.Page
{
MyAdo mycl = new MyAdo();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void BtnLogin_Click(object sender, EventArgs e)
{
Session.Remove("sess_repsq1");
string sl = "select DocNo,VrDate,AccCode,JDesc,AccName_ne,JDebit,JCredit, from V_Journal where Docno <>-1 ";
if (DateFrom.Text != "" || DateTo.Text != "")
{
sl += " and DocDate between '" + DateFrom.Text + " 00:00:00.00'" + " and '" + DateTo.Text + " 23:59:59.000'";
}
mycl.Redirect("Crystal3.aspx?repsq1=" + sl + " order by Docno asc" + "&repname=" + "JournalRep", "_blank", "menubar=0,width=900,height=900");
}
}
|
|
|
|
|
Hi all i am using crystal report for window application & i want to give report load path which can load report on any machine.I used the application startup path method as well dynamic path finding & this one also but not working any one
|
|
|
|
|
I written your posted code but data is not coming in my report
|
|
|
|
|
|
Just what I've been looking for!
|
|
|
|
|
i have applied below method correctly.but it still asking for login info at runtime.
reportDocument.SetDatabaseLogon()
Dilip
|
|
|
|
|
hi, i'm having a lot of problems trying to add parameters to my report,
i'm using VB .net
I'm using this function to add 5 parameters
Private Function AddParameters(ByVal Value As String, ByVal Parameter As String)
discreteVal = New ParameterDiscreteValue()
paramField = New ParameterField()
paramField.Name = Parameter
paramField.ParameterFieldName = Parameter
discreteVal.Value = Value
paramField.CurrentValues.Add(discreteVal)
paramFields.Add(paramField)
End Function
Id= Frm_Loading.Txt_id.Text
AddParameters(Name, "nombre")
AddParameters(Age, "Age")
AddParameters(Date, "Date")
AddParameters(Group, "Group")
AddParameters(Id, "Id")
The parameter "Id" is the content of a textbox in another form, if we put a comment on this line the program shows a windows to put the value of the parameter, but if don't, the program shows a message error, "The parameter is incorrect" Crystal Reports Forms Viewer
any idea about what's wrong
|
|
|
|
|
>>>>>>>>>>SORRY<<<<<<<<<<<<<<<<<<<<<
I finally found the solution to my problem
I was using an incorrect parameter name "name" instead of "name".
Sorry, bye.
|
|
|
|
|
>>>>>>>>>>SORRY<<<<<<<<<<<<<<<<<<<<<
I finally found the solution to my problem
I was using an incorrect parameter name "name" instead of "name".
Sorry, bye.
|
|
|
|
|
Everything seems fine, but i'm wondring why i get an empty display of the "@vDepartment" parameter in the actual report.
thank you.
xxx
|
|
|
|
|
Dear Pankaj,
Code really works fine.Thanks a ton.But i have a small doubt why do we need to reconstruct the paramfield as well as paramDiscreteValue.I am unable to understand. I dont have much idea in oops concept kindly explain me in detail.Is there any other way to pass the parameters to the reports..Let us say iam using 5 different paramters so do i need to declare and instantiate 5 time or what.
|
|
|
|
|
Want to Accespt Parameters with Comma Seperated values.
I want dynamic report in which user selects values using check boxes. I pass them to procedure which is bound to Crystal Report, but the issue is crystal does not show any dynamic data that procedure returns.
My query is working fine with comma seperates values
(Used in statement while selecting: eg.: select a from b where c in (1,2,3))
While passing these values to Crystal, it is not showing any record while procedure shows all.
If i change the procedure to accept single value as parameter, pass single value to RPT, i get the results.
I need to know is there a way to pass comma seperated values to crystal report in a single parameter?
If Anybody has done it? Any help appreciated.
DevIndia
|
|
|
|
|
|
hi
i use these codes for reporting
my proc:
<pre>create proc Cpost
@nopersoneli int
As
Select p.fname,p.lname,p.NoPersoneli,po.name from personal p
Join postpersonal pp
On p.NoPersoneli=pp.Cpersonal
Join post po
On po.code=pp.vpost
</pre>
<pre> ReportDocument reportDocument = new ReportDocument();
ParameterField paramField = new ParameterField();
ParameterFields paramFields = new ParameterFields();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "@NoPersoneli";
paramDiscreteValue.Value = "45";
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
crystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(@"C:\Documents and Settings\Administrator\Desktop\VEZARAT\VEZARAT\PostCrystalReport.rpt");
reportDocument.SetDatabaseLogon("", "", "niloofar\\i2", "vezaratekar", false);
crystalReportViewer1.ReportSource = reportDocument;
</pre>
error:The parameter is incorrect
please help to me
thanks a lot
|
|
|
|
|
Check whether u had added the parameters in the CrystalReport - FieldExplorer in ParameterFields
|
|
|
|
|
hello,at first,thanks for your usefull article
i have one qustion,if i want to write this program with sqldataadaptor and dataset and sqlconnection,is it possible?please guide me.
i wrote that,but i have a an error,"invalid report path',i wonder if you could help me.an my codes:
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
Try
Dim cmd As New SqlClient.SqlCommand("Sel_SalesData", connection)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@vDepartment", "South")
cmd.Parameters.AddWithValue("@iSalesYear", "2004")
If connection.State = ConnectionState.Closed Then
connection.Open()
End If
Dim adapter1 As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(cmd)
adapter1.Fill(dst)
Dim rep As New ReportDocument()
rep.SetDataSource(dst)
CrystalReportViewer1.ReportSource = rep
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
sepideh
|
|
|
|
|
Thanks a lot for posting this (the crystal parameter one), saves a lot of time on my release date!!
adfg
|
|
|
|
|
Thanks and you are welcome
Pankaj A. Chitriv
|
|
|
|
|
CrystalDecisions.CrystalReport.Engine.ParameterFie ldCurrentValueException:
Missing parameter values.
This is the error that I get when the report is subjected to print.
Could you help me solve this?
Ansaf
|
|
|
|
|
Dear Pankaj A. Chitriv,
I look your example and have next question:
I have a report file.rpt and datasource is view (database in SQL Server).
I make a web page and put control crystalreportviewer and crystalreportsource.
In other web page have a gridview and button Report, I need to click button active crystalreport(file.rpt) and pass parameter where currentrowindex is posicionate in gridview.
How make this?
Can you help me please?
Thanks for your help,
Regards.
|
|
|
|
|
I have read your article, first thank you for you time. My questions is pretty straight forward, in your example you know all the stored procedures to call at design time, do you know of a way to get the name of the stored procedures at design time for the Crystal Parameters?
|
|
|
|
|
Hi,
I am working with asp.net 1.1(C#) and i want to show report using Crystal Report 9.0.I have written code to fill ado.net dataset and assign that dataset to crystalreport but it is giving error "LOGON FAILED".
Why this error is coming?
how can i resolve it.
Please Help..............
Thanks
Pramod
|
|
|
|
|
Can you try by giving enableUseridpassword for the crystalreportviewer false and try
|
|
|
|
|
How do we pass sql command parameter to Crystal Report?
For Example: Select * From TABLE Where VALUE = 5
Crystal Report must show the result of this query. Please help me. Thanks.
|
|
|
|
|
Hi!
You should see CrystalReport's RecordSelectionFormula property. You can set Primary key of the table according to you requirement like:
rpt.RecordSelectionFormula = "{YourTable.PrimaryKeyfieldName}=" & Val(TxtCode.Text)
Here:
txtcode.text will contain the value of the PrimaryKeyfieldName of the table.
Hope it helps!
|
|
|
|