hello i created a database 'sa' and add a table 'read' the table contains 2 column 1-no , 2-name when i add a name using a tex box and a button. no. column must update automatically as 0,1,2,3,4,...........
no name
0 sanu
1 edwin
2 tisil
simply i need to add serial no in my database in the column 'no'.
Set the no. column as identity column. So the values are generated automatically. Then from the front end, you must insert only the name using the insert command like:
santana geor...
Member
2 Points
9 Posts
Adding serial no in to .mdf database
Apr 22, 2012 09:46 AM|LINK
hello i created a database 'sa' and add a table 'read' the table contains 2 column 1-no , 2-name when i add a name using a tex box and a button. no. column must update automatically as 0,1,2,3,4,...........
no name
0 sanu
1 edwin
2 tisil
simply i need to add serial no in my database in the column 'no'.
please help me
adeelehsan
All-Star
18223 Points
2725 Posts
Re: Adding serial no in to .mdf database
Apr 22, 2012 09:56 AM|LINK
Set the no. column as identity column. So the values are generated automatically. Then from the front end, you must insert only the name using the insert command like:
insert into read (name) values ('SomeName')
See the following link for more inof:
http://msdn.microsoft.com/en-us/library/ms188059.aspx
MCPD ASP.NET 4.0 and 3.5, MCTS WSS, MOSS, SharePoint 2010, MCT
Microsoft Community Contributor Award 2011
jsiahaan
Contributor
2304 Points
588 Posts
Re: Adding serial no in to .mdf database
Apr 22, 2012 10:11 AM|LINK
Hi,
Here the code, additional to adeelehsan replied, in this case, you do not need to specify column "no" it will automatically generated:
USE [sa] GO CREATE TABLE [dbo].[read] ( [no] INT NOT NULL PRIMARY KEY IDENTITY, [name] NVARCHAR(50) NULL )Have fun
Indonesian Humanitarian Foundation