Solved

How to generate unique id in textbox.

Posted on 2012-03-20
3
181 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
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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