Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2009, 09:07 PM
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Ch 2 pp. 28

I have a compile error on example code to for "Adding a Record."

Here is my sample code from Default.cs for "Insert Button."

Code:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using V2.PaidTimeOffDAL;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
       //Create an instance of the data context
       HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext();

       //Create a new ENTUerAccount object and set the properties
       ENTUserAccount userAccount = new ENTUserAccount
       {
          WindowsAccountName = @"VARALLO1\VaralloMadison",
          FirstName = "Madison",
          LastName = "Varallo",
          Email = "[email protected]",
          IsActive = true,
          InsertDate = DateTime.Now,
          InsertENTUserAccountId = 1,
          UpdateDate = DateTime.Now,
          UpdateENTUserAccountId = 1
       };

       //Signal the context to insert this record
       db.ENTUserAccounts.InsertAllOnSubmit(userAccount);
       //Save the changes to the database
       db.SubmitChanges();
    }
}
(The line receiving the error is in "red.")

Here is my error:

Error 1 The type arguments for method 'System.Data.Linq.Table<V2.PaidTimeOffDAL.ENTUserA ccount>.InsertAllOnSubmit<TSubEntity>(System.Colle ctions.Generic.IEnumerable<TSubEntity>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. C:\Users\Mick\Documents\Visual Studio 2008\Projects\PaidTimeOffSolution\PaidTimeOffUI\De fault.aspx.cs 40 8 http://localhost/PaidTimeOffUI/

If anyone can help it would be greatly appreciated.
Thanks
Mick
 
Old August 20th, 2009, 04:47 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

believe you are missing the

using System.Data.Linq;
 
Old August 20th, 2009, 05:08 PM
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 Pp 28 Error

Thanks for the response. However I still have the error. I added the suggested using statement. I also added a reference to System.Data.Linq; to the website project. I still have the same error?????

Thanks and best regards.
 
Old August 20th, 2009, 05:48 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Try adding one more of this:

using System.Collections.Generic;

P.S. You set home.aspx as the startup page, not default.aspx.
 
Old August 23rd, 2009, 11:35 AM
Registered User
 
Join Date: Aug 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

The method in red line should be InsertOnSubmit (not InsertAllOnSubmit).

This adds "an entity" in a pending insert state.

(The code in p.28 is correct)

DungPT

Last edited by DungPT; August 23rd, 2009 at 01:00 PM..
 
Old August 24th, 2009, 10:03 AM
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default This tip worked.

Thanks for the tip. Just proves four eyes are better than two sometimes. The code complied fine after your suggested changes were implemented.

Thanks
Mick
 
Old August 24th, 2009, 04:13 PM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

My $10 question is, how could your become InsertAllOnSubmit to begin with?
 
Old August 24th, 2009, 04:34 PM
Registered User
 
Join Date: Oct 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default $10 answer

When typing in the code "intellisense" popped up and I must have clicked on it accidentally. I read over the code many times and just never caught it.

Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch 28 A realistic example no app_code folder jgronquist BOOK: Professional Visual Basic 2008 ISBN: 978-0-470-19136-1 0 March 5th, 2009 05:46 PM
Chapter 4 pp. 118-119 luciano991 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 August 13th, 2006 01:56 PM
Hibernate3 LazyInitialization with Ch. 28 grossmaa BOOK: Beginning JavaServer Pages 0 May 25th, 2006 09:46 AM
Ch 28 exercise using Eclipse keeotee BOOK: Beginning JavaServer Pages 1 April 2nd, 2006 12:09 PM
chapter 2 ; pp 59 - 62 ritter BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 4 April 28th, 2004 01:30 AM





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