c# - Incorrect syntax near ')'. while creating table -
i newbie sqlserver , have came across error :
system.data.sqlclient.sqlexception (0x80131904): incorrect syntax near ')'. @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolea n breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception , boolean breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobj ect stateobj, boolean callerhasconnectionlock, boolean asyncclose) @ system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready) @ system.data.sqlclient.sqlcommand.runexecutenonquerytds(string methodname, boolean async, int32 timeout, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.internalexecutenonquery(taskcompletionsou rce`1 completion, string methodname, boolean sendtopipe, int32 timeout, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.executenonquery() @ kellentechnology.program.main(string[] args) in c:\users\mohit\documents\v isual studio 2013\projects\kellentechnology\kellentechnology\program.cs:line 37 clientconnectionid:d9ec7a79-87d2-40f9-83f9-dc7b08c05153
and code error cause connection string below:
string sqlstatement2 = "create table " + table2name + "" + "(line_id autoincrement primary key ," + "line_full_name char(50) not null,"+ " network_id integer foreign key)";
could 1 please let me know cause of problem ? how fix ?
autoincrement
not sql server keyword. think intend:
string sqlstatement2 = "create table " + table2name + "" + "(line_id int not null identity(1, 1) primary key, " + "line_full_name char(50) not null," + " network_id integer foreign key references network(network_id))";
in addition, foreign key
requires table reference.
Comments
Post a Comment