Solved

How to generate unique id in textbox.

Posted on 2012-03-20
3
179 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

773 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