siraj alshami

siraj alshami

  • NA
  • 7
  • 645

How to Create Database & Tables SqlServer in C#

Apr 23 2018 7:54 AM
I want to Create Database & Tables SqlServer in C#
But it not work with my code !!
that's my code >>
string command = "Create Database Checks;" +
"GO" +
"USE Checks;"+
"GO"+
"CREATE TABLE Branches+"+
"(Branch_ID int PRIMARY KEY," +
"Branch_Name+ VARCHAR(30) NOT NULL," +
"Branch_Code VARCHAR(20)," +
"Branch_Address VARCHAR(30) NOT NULL);" +
"Create Table Printers(" +
"Printer_ID int PRIMARY KEY," +
"Printer_Name Varchar(20)NOT NULL);" +
"CREATE TABLE Products(" +
"Product_ID int PRIMARY KEY," +
"Product_code VARCHAR(30)NOT NULL," +
"Product_name VARCHAR(30)NOT NULL," +
"Branch_ID int FOREIGN KEY REFERENCES Branches(Branch_ID));" +
"CREATE TABLE Users(" +
"User_ID int PRIMARY KEY," +
"User_name VARCHAR(20) NOT NULL," +
"F_name VARCHAR(20) NOT NULL," +
"L_name VARCHAR(20) NOT NULL," +
"Creation_date Date," +
"C_U_ID Int," +
"User_privilege Varchar(20)," +
"Status VARCHAR(10)" +
"Last_Access DATE, " +
"Finger_print Varchar(20), " +
"Branch_ID int FOREIGN KEY REFERENCES Branches(Branch_ID)); " +
"Create Table Checks(" +
"Check_ID int PRIMARY KEY, " +
"Check_Sequence Int not null, " +
"User_ID int FOREIGN KEY REFERENCES Users(User_ID), " +
"Branch_ID int FOREIGN KEY REFERENCES Branches(Branch_ID), " +
"Product_ID int FOREIGN KEY REFERENCES Products(Product_ID)" +
"Printed varchar(5) not null, " +
"Create_Date Date, " +
"Printer_ID int FOREIGN KEY REFERENCES Printers(Printer_ID)); " + "";
 

Answers (4)