Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. private void CreateTables()
  2. {
  3. string connStr = @"Data Source=
  4. (LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|
  5. AYttFM.mdf;Integrated Security=True";
  6. using (var connection = new
  7. System.Data.SqlClient.SqlConnection(connStr))
  8. {
  9. try
  10. {
  11. connection.Open();
  12. using (var command = connection.CreateCommand())
  13. {
  14. StringBuilder sb = new StringBuilder();
  15. sb.Append("CREATE TABLE [dbo].[AssignmentHistory] ");
  16. sb.Append("(");
  17. sb.Append("[Id] INT NOT NULL PRIMARY KEY, ");
  18. sb.Append("[WeekOfAssignment] DATE NOT NULL,");
  19. sb.Append("[TalkType] INT NOT NULL,");
  20. sb.Append("[StudentID_FK] INT NOT NULL, ");
  21. sb.Append("[AssistantID_FK] INT NOT NULL, ");
  22. sb.Append("[CounselPoint] INT NOT NULL");
  23. sb.Append(")");
  24.  
  25. command.CommandText = sb.ToString();
  26. command.ExecuteNonQuery();
  27. }
  28. }
  29. catch (Exception ex)
  30. {
  31. MessageBox.Show(ex.Message);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement