?
Solved

How to generate unique id in textbox.

Posted on 2012-03-20
3
Medium Priority
?
186 Views
Last Modified: 2012-03-20
I have a table where records are to be entered.
Initially there are no records.
On frontend, i have a button Generate ID, and a textbox, i want when the user click on this button, automatically 1should come and so on.
This will happen at multiuser levels with one database.
How to put the number generated in textbox.

Please send code.

Table mststudents, id is the field which is primary key identity(1,1) is set.
textbox name is txtuin.
Connection name is con
please send the query.
0
Comment
Question by:searchsanjaysharma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 37741394
>This will happen at multiuser levels with one database

You will have problem at some stage with this code.

Either use Identity column or use a stored procedure to do the insertions

Getting the ID is easier

command.commandtext = "Select IsNull(Count(*), 0) From mytable"

Dim cnt As Integer = command.ExecuteScalar()

txtID.Text = cnt + 1
0
 

Author Comment

by:searchsanjaysharma
ID: 37741421
identity is already set.
how to solve this.
s = "select isnull(max(id),0)+1  from mststudents"
will this be ok, if multiple people are doing the dataentry and all should have separate UIN.
I want all users should get separate uin
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37741630
Ok, ok.
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question