Solved

How to generate unique id in textbox.

Posted on 2012-03-20
3
178 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
Comment Utility
>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
Comment Utility
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
Comment Utility
Ok, ok.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Merging PDFs with VB.NET 10 29
Need help with a query 6 53
visual Basic Net vs c# net 8 52
How to open a link from vb.net app 3 8
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now