Insert data into SQL Server from C# code

前端 未结 7 1895
自闭症患者
自闭症患者 2021-01-06 06:59

I have a table student (id, name). Then I have one textbox, for entering the name, when click on submit button, it inserts the data into the databa

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-06 07:05

    use the key word "identity" to auto increment the id column

    Refer : http://technet.microsoft.com/en-us/library/aa933196(v=sql.80).aspx

    create table table_name( id int PRIMARY KEY IDENTITY ) 
    

    and you no need to mention the "id" in the insert query

提交回复
热议问题