Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 9th, 2009, 05:58 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default Query Builder Help

Having a problem with the Query Builder. I can get all the way to the ReportQuery.aspx but when i click the Preview button I get the following.

Code:

if (QueryBuilder1.GetWhereClause(ref whereClause, ref validationErrors))
{
ENTReportBO currentReport = CurrentReport;
ReportDocument report = newReportDocument();
report.Load(Server.MapPath(currentReport.FileName));
Type objectType = Type.GetType(currentReport.ObjectName);
object listObject = Activator.CreateInstance(objectType);
 
//This is where it fails
object[] data = (object[])objectType.InvokeMember("Select", BindingFlags.InvokeMethod, null, listObject, newobject[] { whereClause });
I get the following error:
"Exception has been thrown by the target of an invocation."

The debugger shows that the data object is null. The SQL that I used in the DAL QueryData file uses a good amount of aggregate functions. Do you think this is the cause. I have looked and doubled check all that I can think of. Also, I added a query filed that is not pulled by the selet statement, but I cant include that field in the Select statement because it has to be apart of an aggregate function which isnt possible (datetime). Any help is appreciated.

Thanks
  #2 (permalink)  
Old November 9th, 2009, 09:03 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Try putting a breakpoint in your Select method and a try/catch block to trap the exception. You'll be able to get a better idea of what is doing on if you get the real error message. It could be as simple as an SQL typo.
  #3 (permalink)  
Old November 10th, 2009, 01:20 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by varallov View Post
Try putting a breakpoint in your Select method and a try/catch block to trap the exception. You'll be able to get a better idea of what is doing on if you get the real error message. It could be as simple as an SQL typo.
Thanks Vince, I did what you suggested and got the following:

Not all code paths return a value
This is thrown in my QueryData SelectClause. Is this saying that I should return void here?
Code:

protectedoverridestring SelectClause()
When I try to change it to void I get an error that says that it must be string to match the overloaded method. I think it may be because of how my SQL is written, it uses several aggregate functions.

Code:

"SELECT DISTINCT AEHospital.REGION, COUNT(CASE WHEN AETransfer.transferDecisionIndex = 0 THEN 'Accepted' END) AS Accepted, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = 1 THEN 'Denied' END) AS Denied, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = - 1 THEN 'No Decision' END) AS NoDecision, COUNT(AETransfer.transferDecision) " +
"AS Total ";
  #4 (permalink)  
Old November 10th, 2009, 01:36 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

the method should return a string. Are you missing the "return" keyword in the body of your method?
  #5 (permalink)  
Old November 10th, 2009, 01:40 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

no sir, everything is there from what I can tell, do you think since I am using a Select Distinct I need to include the Group By somewhere?

Code:
publicclassReportTransferByRegionQueryData : ENTBaseQueryData<ReportTransferByRegionResult>
{
protectedoverridestring SelectClause()
{
try
{
return"SELECT DISTINCT AEHospital.REGION, COUNT(CASE WHEN AETransfer.transferDecisionIndex = 0 THEN 'Accepted' END) AS Accepted, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = 1 THEN 'Denied' END) AS Denied, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = - 1 THEN 'No Decision' END) AS NoDecision, COUNT(AETransfer.transferDecision) AS Total";
}
catch
{ }
 
}
protectedoverridestring FromClause()
{
return"FROM AETransfer INNER JOIN AEHospital ON AETransfer.AEHospitalId = AEHospital.AEHospitalId";
}
  #6 (permalink)  
Old November 10th, 2009, 01:44 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

You shouldn't.

The Select method does not execute the statement. Are you getting an error in the Select method or somewhere else? Also, check to make sure when the Select and From statements are appended together that there is a space before the FROM clause.
  #7 (permalink)  
Old November 10th, 2009, 02:00 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

the compiler shows this

'V2.PaidTimeOffDAL.Reports.ReportTransferByRegionQ ueryData.SelectClause()': not all code paths return a value

Perplexing no? I built the standalone report using the report viewer to make sure the SQL was error free and it works there no problems. Cant figure out for the life of my what is going on here though.

Reports and the datatable schemas should all be built as there were in Chapt 9 correct?
  #8 (permalink)  
Old November 10th, 2009, 02:07 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

you're getting the compile error because the Catch block doesn't return anything.
  #9 (permalink)  
Old November 10th, 2009, 02:29 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Changed try/catch block to this
Code:
protectedoverridestring SelectClause()
{
try
{
return"SELECT DISTINCT AEHospital.REGION, COUNT(CASE WHEN AETransfer.transferDecisionIndex = 0 THEN 'Accepted' END) AS Accepted, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = 1 THEN 'Denied' END) AS Denied, " +
"COUNT(CASE WHEN AETransfer.transferDecisionIndex = - 1 THEN 'No Decision' END) AS NoDecision, COUNT(AETransfer.transferDecision) AS Total ";
}
catch (InvalidCastException e)
{ throw (e); }
Compiled clean, try to run report and the original error is thrown.
Code:
 
Exception has been thrown by the target of an invocation.
What I can state specifically about the following line in ReportQuery.aspx.cs
Code:
object[] data = (object[])objectType.InvokeMember("Select", BindingFlags.InvokeMethod, null, listObject, newobject[] { whereClause });
Is the data object is coming back null. The objectType and listObject are set properly. I would expect data to be set to ReportTransferByRegionResult since.
Code:
publicclassReportTransferByRegionQueryData : ENTBaseQueryData<ReportTransferByRegionResult>
I checked the Result in ORM designer and cant find anything wrong with it. The Result should be similar to the stored procedure since that is what it derives from correct? Since the standalone report works with the ReportViewer.aspx can there be somethign in the Results that may prevent this from working properly?

Last edited by ZeroFactorial; November 10th, 2009 at 02:37 PM..
  #10 (permalink)  
Old November 10th, 2009, 08:46 PM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Put a breakpoint in the Select method and then step through the code until the error occurs. The error is happening inside the Select method. You should get the real exception object instead of the generic exception you are currently getting.
The Following User Says Thank You to varallov For This Useful Post:
ZeroFactorial (November 11th, 2009)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
course builder youyou_hym Dreamweaver (all versions) 1 May 28th, 2008 03:09 AM
sql query builder windw size problem the_dude ASP.NET 2.0 Basics 0 January 25th, 2007 01:37 PM
Looking for a SQL Query Builder for ASP.Net/Oracle rashid_masud SQL Language 0 March 9th, 2006 06:37 AM
Query Builder Help Dwizz Access 1 April 25th, 2005 05:11 AM
how to launch Query Builder tz478 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 March 29th, 2005 10:54 AM



All times are GMT -4. The time now is 10:06 PM.


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