C# 创建数据库和表

 

using (SqlCommand command2 = new SqlCommand("CREATE TABLE bases(id int IDENTITY(1, 1) PRIMARY KEY not null,basename char(50),category char(10))", conn))
                        { command2.ExecuteNonQuery(); }

                        using (SqlCommand command3 = new SqlCommand("CREATE TABLE maps(id int IDENTITY(1, 1) PRIMARY KEY not null,mapname char(50),description1 char(500),filename char(13),filedate char(8),datedtime timestamp,baseid int,category char(50))", conn))
                        { command3.ExecuteNonQuery(); }

                        using (SqlCommand command4 = new SqlCommand("CREATE TABLE category(id int IDENTITY(1, 1) PRIMARY KEY not null,cname char(50))", conn))
                        { command4.ExecuteNonQuery(); }

                        using (SqlCommand command5 = new SqlCommand("INSERT INTO  category(cname) VALUES('jointops')", conn))
                        { command5.ExecuteNonQuery(); }

 

posted @ 2019-03-15 15:40  JackJu  阅读(11016)  评论(0编辑  收藏  举报