Click here to Skip to main content
11,925,292 members (62,781 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# SQL-Server C#4.0
Hi friends,
I created sql table with studentID column as a autoincreamented I want to show the Id from sql to textbox.Before any insertion of data there is no Id on the table. At that time I want show First value in textbox and then show next autoincremented value from sql table for every insertion.Plase help me how can i do this.
Thanks in advance
Posted 12-Oct-12 22:20pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Stop and think about it.
Why are you showing the value at all? So that people know what value will be assigned to the new record they are creating. But the main reason for using SQL is that it supports multiple users at the same time, so the "next value" won't be the next one - that value may have been used by a different user two hours ago.

That leads to confusion - only show information when it will be correct - which in the case of auto incremented data is only after the record has been inserted correctly.

If you need to give the user the record id, then there is probably something wrong with your data design.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100