 |
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
|
|
|
|

December 21st, 2010, 05:16 PM
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|

December 21st, 2010, 05:20 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Take a look at page 423 and further and the accompanying exercise.
Cheers,
Imar
|

December 21st, 2010, 05:28 PM
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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..
|

December 21st, 2010, 06:02 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|

December 21st, 2010, 06:37 PM
|
Authorized User
|
|
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Complicated
Your tip helped. But all seems to be so complicated, coming from VB6!
|

December 22nd, 2010, 05:21 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |
|