DataGridView: Need to make Enter key create newline in textbox. Discussion in 'Microsoft C#.NET' started by Steve K, May 11, 2008. I want to genrete a auto number in my project. I used vb.net 2008 and SQl server 2005 as backend?? I want to create a serial no that is like abc/2010/01.In this. The abc is same in all the.
i used vb .net 2008 and SQl server 2005 as backend ??
i want to create a serial no that is like abc/2010/01..In this..
the abc is same in all the serial no.
the 2010 is used from the running Year.(using date for year)
the 01 is a actual serial no that can be auto genrete...
But how can i do this ....?? and How can i find max number from my serial no.....???how can i maintain it if i delete it then all after delete serial no will place it's place..(there is no break in serial no on delete)??????Please help me.....
here is the code snippet for generate newidi have taken a simple label and textbox label will auto generate newid and textbox will insert a new record in databasetake a label and textbox in your design page
The main thing is that you should maintain your incremented number somewhere, In my case i have used textbox and label.
But I did rather recommend you to go for GUID or Random Number.
You could store the serial numbers in a database table where the third component of the number is the primary key of the table as an identity field. Any time you create a new serial number, you'd insert the current year and the static text into the table. An easy way to do this would be to wrap that logic in a stored procedure which takes no arguments, internally inserts the current year and the text, and returns the entire serial number as a single scalar value.
Something like:
INSERT INTO SerialNumbers (Year, Name) VALUES (year(getdate()), 'abc')
and:
SELECT Name + '/' + CAST(Year AS nvarchar) + '/' + CAST(ID AS nvarchar) FROM SerialNumbers WHERE ID = SCOPE_IDENTITY()