Display data from an ID in the table in a textbox - C#

Asked

Viewed 207 times

0

I need to make one select in the database to capture the id of the last product registration, I will make an increment and show it in a textbox on my registration form. My intention is to show the user what will be the next id product that will be registered.

How can I transform this information from select to display it on textBox?

  • 2

    What is the database? And if two people are registering at the same time?

  • @Robertodecampos is completely right, I recommend using a sequence in the bank to solve this problem

  • ever thought that the id, in most cases, matters little to the user ?! display a prediction of which id will be generated in the database so... I see no benefit in doing this, will only bring problems and difficulties

  • so actually this was a component of a gambiarra, I need actually the id data so that when the product is registered I send this information to another table of the SQL Server database

  • @Joãoávila is not the best practice, but you can make a SELECT ISNULL(MAX(ID),0) +1 FROM TABELA and you will have the next ID to be entered.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.