Skip to content
Advertisement

Call the maximum from SQL table to textbox

I am working on a Windows Forms C# application and I need to auto generate my invoice number from my database. For that I need to get the maximum value from the database and want to add one with the max value in db, any idea

Advertisement

Answer

You could design your database table using an IDENTITY column. The database will assign a next value for the inserted row. You can access the value using one of: SCOPE_IDENTITY, @@IDENTITY or IDENT_CURRENT. More can be found here: MSDN-Identity.

To know the difference between SCOPE_IDENTITY and @@IDENTITY see here.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement