I try using Sql Identity in my table for No column. If I try insert value from table with c#, always insert "0" and Identity not working. How can I fix this?
SqlCommand Cmd_IdentityOpen;
string SqlIdentityOpen = "SET identity_insert " + cbbox_ltable.Text + " on";
SqlIdentityOpen += " INSERT INTO " + cbbox_ltable.Text + " ([No], [Computer ID], [Name Surname] ) Values ('" + txtbox_lno.Text + "' , '" + cbbox_lcid.Text + "' , '" + txtbox_lnamesurname.Text + "' )";
Cmd_IdentityOpen = new SqlCommand(SqlIdentityOpen, con);
con.Open();
Cmd_IdentityOpen.ExecuteNonQuery();
con.Close();
Table Code
SqlTableCreate += "CREATE TABLE " + txtbox_ltablename.Text + " ([No] int not null IDENTITY(1,1) PRIMARY KEY, [Computer ID] nvarchar(50), [Name Surname] nvarchar(50) )";