 |
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : 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
|
|
|
|
|

February 15th, 2017, 06:55 PM
|
|
Authorized User
|
|
Join Date: Apr 2016
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Ch 13 - Try It Out, DetailsView, p450. Id Number.
Hi,
P450: Try It Out - Inserting Data with the DetailsView Control, p450.
Step 7.
I inserted a new genre: Name: Disco, with SortOrder: 10. It inserted ok, except the Id number was 4 digits. I deleted it, tried again, and the same thing. Id number shows with 4 digits: 1003.
Any idea why that happens?
-Thanks!
|
|

February 21st, 2017, 10:59 PM
|
|
Authorized User
|
|
Join Date: Apr 2016
Posts: 11
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
After you responded, I had gone into SSMS and verified that the identity increment and seed were both still set to 1. I queried the Genre table, and the newly added genre: Disco was listed with an Id of 13, not 1003 as it was in gridview.
Yesterday, I went into SSMS and the PlanetWrox db was not listed in object explorer. I was able to successfully attach it though. Checked that the above settings were still the same, and queried the Genre table. This time the new genre: Disco was not listed. I went into VS, displayed the Genre web page and the newly added genre: Disco is not there anymore either.
So I inserted the new genre: Disco using the Genre web page. The Id displayed in gridview as 1004. I went back into SSMS, queried the Genre table and the newly added genre was listed in the result with an Id of 1004 there as well. It's weird that the first time the Id displayed in gridview as 1003, yet displayed in SSMS as 13. Then this time the Id displayed in both gridview and SSMS as 1004. It seems to be inserting 00 in the middle of the Id value: i.e. 13 becomes 1003, 14 becomes 1004, etc.
Apparently this is not uncommon, as per the link you provided. I've accepted that it's some type of quirk with SQL Server 2012 (and perhaps the interaction with gridview, detailsview or VS?) and can live with that. Will this cause any problems getting through the rest of the book?
-Thanks!
|
|

February 22nd, 2017, 04:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
>> It seems to be inserting 00 in the middle of the Id value: i.e. 13 becomes 1003, 14 becomes 1004, etc.
That shouldn't happen. Are you sure you're looking at the same database each time? Maybe you connected to a different database in SSMS?
>> Will this cause any problems getting through the rest of the book?
The jump in IDs won't cause problems. You just need to be aware that your numbers could be different from mine. In general, you shouldn't expect identities to always be exactly sequential. If you need a truly sequential number you can use SQL Server's Sequence functionality. For the primary keys of all the tables in the book that's not needed though.
Imar
|
|
 |
|