Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
str = "CREATE TABLE dbo.UserInfo(ID INT IDENTITY(1,1) PRIMARY KEY,name varchar(50) ,FormatColumn AS RIGHT('LS_00' + CAST(ID AS VARCHAR(8)), 8) PERSISTED)";
SqlCommand cmd = new SqlCommand(str, con);
cmd.ExecuteNonQuery();

I Use this code in sql but when i run this code in access detabase it show error plz help me out . i want to create a specific code Like _

ADM_001 . which is autogenertae formate in access database
Posted
Comments
Abhinav S 5-Feb-14 11:50am    
Check if that table already exists.
Rohit85 5-Feb-14 11:56am    
i want use this code in ms access
ZurdoDev 5-Feb-14 11:53am    
Access does not have the same syntax as SQL Server. See http://msdn.microsoft.com/en-us/library/office/bb177893(v=office.12).aspx

1 solution

Hi,

There is no SQL IDENTITY equivalent keyword in MSAccess. you should use "INT IDENTITY(1,1) PRIMARY KEY" instead of "COUNT AUTOINCREMENT NOT NULL PRIMARY KEY"... please use correct Equivalent ANSI SQL Data Types

Refer this link
http://msdn.microsoft.com/en-us/library/bb177899.aspx

i hope this ll hep you

Regards and thanks
Sarva
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900