Click here to Skip to main content
15,880,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have designing in my web page ok the error are occur report in asp.net


The error
An error has occurred during report processing.
Invalid cast from 'Boolean' to 'DateTime'.

My code
public partial class ManualReport : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack == true)
        {
            populatecombobox();
        }
    }
    private void populatecombobox()
    {
        DataSet Ds;
        Ds = new DataSet();
        SqlCommand Cmd = new SqlCommand();
        SqlDataAdapter Adp = new SqlDataAdapter();
        SqlConnection Cnn = new SqlConnection();
        string ConnectionString;
        ConnectionString = ConfigurationManager.ConnectionStrings["PhotostudioConnectionString"].ConnectionString;
        Cnn.ConnectionString = ConnectionString;
        if (Cnn.State != ConnectionState.Open)
            Cnn.Open();
        Cmd.Connection = Cnn;
        Cmd.CommandType = CommandType.StoredProcedure;
        Cmd.CommandText = "UspGetDataFromtblManualphotoseettingsMaster";
        Cmd.Parameters.Clear();
        //Cmd.Parameters.AddWithValue("@Id", Id);
        Adp.SelectCommand = Cmd;
        try
        {
            Adp.Fill(Ds);
        }
        catch (Exception ex)
        {
            throw new ApplicationException(
                "!!! An Error Occured While getting Data From tblSize." + ex.Message);
            lblError.Visible = true;
            lblError.Text = "!!! An Error Occured While " + ex.Message.ToString();
            return;
        }
        if (Ds.Tables[0].Rows.Count > 0)
        {


        }
        Cmd.Dispose();
        Cnn.Close();
        Cnn.Dispose();
        return;

    }


    protected void btnShow_Click(object sender, EventArgs e)
    {
        ReportViewer1.LocalReport.Refresh();
        ReportViewer1.Visible = true;
    }

}



My store proce


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go









--select * from tblSize
--sp_help tblPhotosettingsMaster
--sp_help tblPhotosettings_transaction
--sp_help tblSize
--[uspTransactionPhotoSettingsDetail] 'raju','4/1/2011','4/27/2011',0,0,0
--[uspTransactionPhotoSettingsDetail] 'ram','01-Apr-2011','03-Apr-2011',0,0,0
--select getdate()
ALTER Procedure [dbo].[uspTransactionManualPhotoSettingsDetail]
(


@Date DateTime,
@DeliveryDate DateTime,


@DateAll As int,
@DelivDateAll As int


)
As
Begin
Declare @Table Table
(
CustomerName Varchar(200),
Phoneno varchar(50),
Size varchar(50),
Noofcopies Numeric,
Rate Numeric,
TotalAmount Numeric,
Date DateTime,
DeliverDate DateTime,
PaidAmount Numeric,
UnPaidAmount Numeric,
ID Numeric,
Int1 Numeric(18,2),
Int2 Numeric(18,2),
Int3 Numeric(18,2),
Int4 Numeric(18,2),
Str1 Varchar(100),
Str2 Varchar(100),
Str3 Varchar(100),
Str4 Varchar(100),
Str5 Varchar(100)
)
Insert into @Table
Select
[Name] As CustomerName,
Phoneno,
Size,
Noofcopies,
Rate,
Total As TotalAmount,
Startdate As [Date],
Enddate As DeliverDate,
PaidAmount,
0,
tblManualPhotosettingsMaster.Id,
0 As Int1,---CreditAmount
0 As Int2,
0 As Int3,
0 As Int4,
'' As Str1,
'' As Str2,
'' As Str3,
'' As Str4,
'' As Str5

From
tblManualPhotosettingsMaster
Join tblManualPhotosettings_transaction on
tblManualPhotosettings_transaction.Id=tblManualPhotosettingsMaster.Id
Join tblSize on
tblManualPhotosettings_transaction.SizeID=tblSize.SizeId
Where
-- ((Convert(DateTime,Convert(VarChar(11),Startdate,106),106)>=@Date and Convert(DateTime,Convert(VarChar(11),Startdate,106),106)<=@Date)) And
-- ((Convert(DateTime,Convert(VarChar(11),Enddate,106),106)>=@DeliveryDate and
--(Convert(DateTime,Convert(VarChar(11),Enddate,106),106)<=@DeliveryDate)) And
-- ([Name]=@CustomerName))
/*Convert(DateTime,Convert(VarChar(11),Startdate,106),106)=Convert(DateTime,@Date,103)
And Convert(DateTime,Convert(VarChar(11),Enddate,106),106)=Convert(Datetime,@DeliveryDate,103) and
[Name]=@CustomerName*/
Convert(DateTime,Convert(VarChar(11),Startdate,106),106)=Convert(DateTime,Convert(VarChar(11),@Date,106),106)
And Convert(DateTime,Convert(VarChar(11),Enddate,106),106)= Convert(DateTime,Convert(VarChar(11),@DeliveryDate,106),106)

Update
@Table
Set
UnPaidAmount=isnull(A.Rate,0) -isnull(PaidAmount,0)
From
(
Select
Sum(Isnull(Total,0)) As Rate,
ID As Sid
From
tblManualPhotosettings_transaction
Group By ID
) A
Where ID=Sid

select * from @Table
End
Posted
Updated 12-Jun-11 22:14pm
v4
Comments
Shahriar Iqbal Chowdhury/Galib 13-Jun-11 2:31am    
Share the code

1 solution

There is no Error in your code.
You need to show code of stored procedure and also need to show used table structure which are used in the stored procedure to get perfect answer.
 
Share this answer
 
v2
Comments
Dalek Dave 13-Jun-11 3:49am    
Minor spelling error corrected.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900