I am database beginner and I was doing AUTOINCREMENT
on creating table, but the following error occurred:
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ','.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolea
n breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception
, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObj
ect stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand
cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,
TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName,
Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSou
rce`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean
asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at KellenTechnology.Program.Main(String[] args) in c:\Users\Mohit\Documents\V
isual Studio 2013\Projects\KellenTechnology\KellenTechnology\Program.cs:line 39
ClientConnectionId:1629d6a5-8e66-445b-99b1-b009103d0343
♂Data base Connection Closed.
My code to do this is :
string sqlStatement = "CREATE TABLE " + Table1Name + ""
+ "(network_id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "network_full_name VARCHAR(50) NOT NULL)";
Could some one please let me know what's wrong with it? I also found somewhere not null identity(1, 1)
instead of autoincrement
but how the two are different?