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: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 12th, 2010, 12:59 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default Chapter 14 Page 483

I am getting an error in the code behine of the first try it out in chapter 14.
I think its related to the chapter 13 but i am not able to figure it our or may it's only a mistake in chapter 14.
This is my cod behind file:
Code:
public partial class Reviews_All : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        using (PlanetWroxEntities myEntities = new PlanetWroxEntities())
        {
            var allReviews = from review in myEntities.Reviews
                             where review.Authorized == true
                             orderby review.CreateDateTime descending
                             select review;
            GridView1.DataSource = allReviews;
            GridView1.DataBind();
        }
    }
}
The error i get is this in red:
Code:
Line 14:         {
Line 15:             var allReviews = from review in myEntities.Reviews
Line 16:                              where review.Authorized == true
Line 17:                              orderby review.CreateDateTime descending
Line 18:                              select review;
Any kind of input is welcome to get me started:
Thanks in advance for your time.
Tariq
Reply With Quote
  #2 (permalink)  
Old September 12th, 2010, 02:59 PM
Authorized User
 
Join Date: Jun 2010
Location: Sneek, Netherlands
Posts: 24
Thanks: 10
Thanked 0 Times in 0 Posts
Default

what is the error message you get? Because I came across the same yesterday (maybe)...
Reply With Quote
  #3 (permalink)  
Old September 12th, 2010, 07:04 PM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Thanks for looking into it:
This is the error i get:

Code:
Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1593: Delegate 'System.Func<PlanetWroxModel.Review,int,bool>' does not take 1 arguments

Source Error:

 

Line 14:         {
Line 15:             var allReviews = from review in myEntities.Reviews
Line 16:                              where review.Authorized == true
Line 17:                              orderby review.CreateDateTime descending
Line 18:                              select review;
 

Source File: c:\BegASPNETCS\Site\Reviews\All.aspx.cs    Line: 16
Reply With Quote
  #4 (permalink)  
Old September 13th, 2010, 02:04 AM
Authorized User
 
Join Date: Jun 2010
Location: Sneek, Netherlands
Posts: 24
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Hey Tariq,

I had a somewhat similar error, which showed up as an error in the same codeblock. In my case something got changed in my web.config (targetFramework). Only difference is that in my case the error was in the 'Using' statement.

I guess in your case too, that it isn't a syntax error, but what it is???

Greetz from Sneek
Reply With Quote
  #5 (permalink)  
Old September 13th, 2010, 02:46 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Tariq,

That code looks fine to me.

Are you sure you created the Entity Framework model correctly? Do you get IntelliSense on the myEntities variable? Do you see any other errors in the Error List of Visual Studio?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #6 (permalink)  
Old September 13th, 2010, 07:14 AM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

thanks for the reply Imar i got it fixed by changing the spelling of:

Authorized
to
Athorized

without a 'u'.
not sure why is that?

Tariq
Reply With Quote
  #7 (permalink)  
Old September 13th, 2010, 08:19 AM
Authorized User
 
Join Date: Jul 2010
Posts: 23
Thanks: 7
Thanked 2 Times in 1 Post
Default

You probably wrote it wrong when you made the attribute in the Reviews table
Reply With Quote
The Following 2 Users Say Thank You to andreas5 For This Useful Post:
Imar (September 13th, 2010), tariq (September 14th, 2010)
  #8 (permalink)  
Old September 13th, 2010, 08:35 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Or you misspelled the column name when you created the database.

You can fix the database and update or recreate the model, or you can just fix the name in the model and leave the database as it is.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #9 (permalink)  
Old September 14th, 2010, 07:10 AM
Authorized User
 
Join Date: Jun 2010
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Default

Yes i spelled it Athorized that is why i was getting an error.
Thanks for that and hope to chat 2 u if another issure arises.

Tariq
Reply With Quote
  #10 (permalink)  
Old September 14th, 2010, 08:47 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

But does that also mean you're not using IntelliSense to the max by letting it complete the property name for you (misspelled or not)?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


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
Chapter 14 Page 548 Try it Out andreas5 BOOK: Beginning ASP.NET 4 : in C# and VB 7 August 22nd, 2010 07:48 AM
Chapter 14 (Page 483) CSS Declaration jsymons BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 11 September 18th, 2009 07:14 AM
Errata: Page 483 drupalmeister BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 June 22nd, 2009 01:32 AM
Chapter 14 page 491 Will BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 April 25th, 2009 04:52 AM



All times are GMT -4. The time now is 05:20 PM.


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