Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
Register | 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 Display Modes
  #1 (permalink)  
Old February 21st, 2016, 04:56 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 14 - EntitySqlException

I receive the following error when I try and view the ManagePhotoAlbum.aspx file in the browser:


System.Data.EntitySqlException: 'PhotoAlbumId' is not a member of type 'PlanetWroxModel.PhotoAlbum' in the currently loaded schemas. Near simple identifier, line 6, column 4.

Any clues on what this means and how to go about resolving it is greatly appreciated.
Reply With Quote
  #2 (permalink)  
Old February 21st, 2016, 06:03 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,957
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

Hi there,

If you follow along with the book, the error message is correct, and PhotoAlbum would not have a property called PhotoAlbumId. but only one called Id.

The question is: why does your code reference
PhotoAlbumId which is hard to answer without seeing your code for
ManagePhotoAlbum.aspx.

Cheers,

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
  #3 (permalink)  
Old February 23rd, 2016, 07:12 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for taking the time to help me resolve my issue. Here is the code for ManagePhotoAlbum.aspx, as suggested:

Code:
 <%@Page Title="Manage Photo Album" Language="VB" MasterPageFile="~/MasterPages/Management.master" AutoEventWireup="false" CodeFile="ManagePhotoAlbum.aspx.vb" Inherits="ManagePhotoAlbum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" 
        DataSourceID="EntityDataSource1" InsertItemPosition="LastItem">
               
          <InsertItemTemplate>
            <li style="">
            Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
            ToolTip:
                <asp:TextBox ID="ToolTipTextBox" runat="server" Text='<%# Bind("ToolTip") %>' />
                <br />
            ImageUrl:
                <asp:TextBox ID="ImageUrlTextBox" runat="server" 
                    Text='<%# Bind("ImageUrl") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                    Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Clear" />
            </li>
        </InsertItemTemplate>
        
        <ItemTemplate>
            <li style="">
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" 
                    Text='<%# Eval("Description") %>' />
                <br />
                ToolTip:
                <asp:Label ID="ToolTipLabel" runat="server" Text='<%# Eval("ToolTip") %>' />
                <br />
                ImageUrl:
                <asp:Label ID="ImageUrlLabel" runat="server" Text='<%# Eval("ImageUrl") %>' />
                <br />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" />
            </li>
        </ItemTemplate>
        <LayoutTemplate>
            <ul class = "ItemContainer">
               <li runat="server" id="itemPlaceholder" />
            </ul>
        </LayoutTemplate>
        
    </asp:ListView>
    
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=PlanetWroxEntities1" 
        DefaultContainerName="PlanetWroxEntities1" EnableDelete="True" 
        EnableFlattening="False" EnableInsert="True" EntitySetName="PhotoAlbums" 
        Where="it.PhotoAlbumId = @photoAlbumId">
        <WhereParameters>
            <asp:Parameter Name="PhotoAlbumId" Type="Int32" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
Again, many thanks for your help
Reply With Quote
  #4 (permalink)  
Old February 24th, 2016, 05:01 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,957
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

Ah that explains it. Your Where clause is wrong, and your Where parameter is off.

The Where clause should read:

Where="it.PhotoAlbum.Id = @photoAlbumId"

As it filters the ID of the PhotoAlbum based in the photoAlbumId parameter.

That param should then look like this:

<WhereParameters>
<asp:QueryStringParameter Name="PhotoAlbumId" QueryStringField="PhotoAlbumId" Type="Int32" />
</WhereParameters>

Hope this helps,

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
  #5 (permalink)  
Old February 24th, 2016, 05:19 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2016
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your continued time and assistance. I fixed the where clause, as directed, but now a new error is thrown:

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: BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Source Error:


Line 4: Inherits System.Web.UI.Page
Line 5:
Line 6: Protected Sub EntityDataSource_Inserting(sender As Object, e As System.Web.UI.WebControls.EntityDataSourceChanging EventArgs) Handles EntityDataSource1.Inserting
Line 7: Dim photoAlbumId As Integer =
Line 8: Convert.ToInt32(Request.QueryString.Get("PhotoAlbu mId"))


Source File: C:\BegASPNET\Source\Chapter 07\ManagePhotoAlbum.aspx.vb Line: 6

The code for ManagePhotoAlbum.aspx.vb reads:

Code:
 
Imports PlanetWroxModel

Partial Class ManagePhotoAlbum
    Inherits System.Web.UI.Page

    Protected Sub EntityDataSource_Inserting(sender As Object, e As System.Web.UI.WebControls.EntityDataSourceChangingEventArgs) Handles EntityDataSource1.Inserting
        Dim photoAlbumId As Integer =
            Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"))
        Dim myPicture As Picture = CType(e.Entity, Picture)
        myPicture.PhotoAlbumID = photoAlbumId

    End Sub
End Class
Any ideas? Again, thanks so much. Shane
Reply With Quote
  #6 (permalink)  
Old February 24th, 2016, 09:22 AM
Imar's Avatar
Wrox Author
Points: 71,164, Level: 100
Points: 71,164, Level: 100 Points: 71,164, Level: 100 Points: 71,164, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,957
Thanks: 79
Thanked 1,556 Times in 1,533 Posts
Default

Could there be a mismatch between your Markup and Code Behind? Based on what you posted there's no explanation for this error but your code and markup may have changed by now. When posting questions like this please:

a) Google for the error message first

b) if that doesn't help, provide all the relevant code. In this case that would be the markup as well as the code behind.

Cheers,

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
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
help in chapter 14 please nawar youssef BOOK: Beginning PHP 5.3 3 October 28th, 2011 12:36 AM
Chapter 14, first 'Try It Out' alharlow BOOK: Beginning ASP.NET 4 : in C# and VB 5 March 18th, 2011 06:00 AM
chapter 14 vthunder70 BOOK: Beginning ASP.NET 2.0 and Databases 2 October 3rd, 2007 03:11 PM
Chapter 14 example pkumar@ech BOOK: Professional Jakarta Struts 0 November 15th, 2006 09:10 AM
Chapter 14 JonG BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 March 21st, 2006 10:04 PM



All times are GMT -4. The time now is 01:20 AM.


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