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
?
What is the database? And if two people are registering at the same time?
– Roberto de Campos
@Robertodecampos is completely right, I recommend using a
sequence
in the bank to solve this problem– Marco Giovanni
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
– Rovann Linhalis
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
@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.– Evandro