Wrox Programmer Forums
|
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 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 December 21st, 2010, 05:16 PM
Authorized User
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default Incremental key index

Hello
I'm looking for a way to create an unique index number (ID number) that increments with every row added, and will not be reused even if a row is deleted. In Access there is a handy function (AutoNumber).
Thanks.
 
Old December 21st, 2010, 05:20 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Take a look at page 423 and further and the accompanying exercise.

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!
 
Old December 21st, 2010, 05:28 PM
Authorized User
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default New Yellow Screen of Death

Now I get the following error:
Operand type clash: uniqueidentifier is incompatible with int

Here is my code


Using myentities As New abeolEntities
Dim user As tbl_user
user = New tbl_user
user.firstname = myControl1.Text
user.lastname = myControl2.Text
user.username = myControl3.Text
user.email = myControl4.Text
user.date_added = DateTime.Now
myentities.AddTotbl_user(user)
myentities.SaveChanges()
End Using

The site crashes at the line myentities.SaveChanges().
The Id field is an int, as Identity defined.
Thanks for the help.

Last edited by avidan; December 21st, 2010 at 05:36 PM..
 
Old December 21st, 2010, 06:02 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Maybe you changed the type of a column in the database after you created the EF model? If so, try recreating the model.

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!
 
Old December 21st, 2010, 06:37 PM
Authorized User
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default Complicated

Your tip helped. But all seems to be so complicated, coming from VB6!
 
Old December 22nd, 2010, 05:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, yes, some of it is more complicated and some of it fortunately only looks more complicated.

Once you get the hang of Entity Framework, I think you'll appreciate how easy it is to do data access without writing a lot of manual code.

Good luck; I am sure it's worth it....

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
allow duplicate values in index key pawatz70 Access 3 November 12th, 2007 07:41 PM
Multiple-key index umeshtheone Pro VB 6 3 October 30th, 2007 07:50 AM
Incremental Loads Johnslg BOOK: Expert SQL Server 2005 Integration Services ISBN: 978-0-470-13411-5 0 August 29th, 2007 07:13 AM
using 3 XPaths to index using xsl:key Chamkaur XSLT 3 March 2nd, 2007 04:09 AM
Incremental ETL KelMan BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 February 27th, 2006 09:01 PM





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