p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio (http://p2p.wrox.com/forumdisplay.php?f=477)
-   -   Chpt 9 Reporting (http://p2p.wrox.com/showthread.php?t=76523)

ZeroFactorial October 8th, 2009 05:16 PM

Chpt 9 Reporting
 
Trying to get a report to print from the Print Button on a GridView Page.

When I run the report I get the following error.
Code:

DataSet does not support System.Nullable<>.
This are my SP, DAL, BLL

Stored Procedure
Code:


ALTER PROCEDURE
dbo.ReportTransfersPastWeek
AS
SET NOCOUNT ON
SELECT RequestDate, pName, dob, transFacility, transferReasons, transferDecision
FROM AETransfer

WHERE RequestDate >= dateadd(day, datediff(day,0,GetDate())-7,0)
RETURN

This pulls the entries from the current date to the last 7 seven days.


DAL
Code:

publicclassReportTransfersPastWeekData
{
publicstaticList<ReportTransfersPastWeekResult> SelectPastWeekTransfers()
{
using (HRPaidTimeOffDataContext db = newHRPaidTimeOffDataContext(DBHelper.GetHRPaidTimeOffConnectionString()))
{
return db.ReportTransfersPastWeek().ToList();
}
}
}


BLL
Code:

publicclassReportTransfersPastWeek
{
publicstaticobject[] SelectPastWeekTransfers()
{
returnReportTransfersPastWeekData.SelectPastWeekTransfers().ToArray();
}
}
}

The error happens on this line of code in the GridView Page.
Code:

void Master_PrintButton_Click(object sender, EventArgs e)
{
ReportDocument report = newReportDocument();
report.Load(Server.MapPath(
"Reports/TransfersPastWeek.rpt"));
//Get the data
report.SetDataSource(ReportTransfersPastWeek.SelectPastWeekTransfers()); <<<Fails
report.ExportToHttpResponse(
ExportFormatType.PortableDocFormat, Response, false, "");
}


Any help would be appreciated. I ran my SQL on the data and it returns valid results. What is going on with the code and design pattern?

ZeroFactorial October 9th, 2009 02:50 PM

Was able to figure this out. Datasets can't except nullable types that is what the error was eluding to. The only thing that was throwing me off what that it allowed me to make a dataset with types that it couldnt handle. So MS should either notify you or build datasets so they except nullable types.

Geesh chasing this down for nothing. So when building your tables and databases it would appear to be best practice or (forced practice) to not allow nullables for fields.

Hope this helps someone out and please let me know if you have any questions.

-Zero


All times are GMT -4. The time now is 04:29 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.