Fredin

Untitled

Oct 11th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. namespace PlanningCalendar
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         private String connectionString = "Data Source=.\\DATABAS;Initial Catalog=TestDB1;Integrated Security=SSPI;";
  11.         private SqlConnection connection;
  12.        
  13.         public void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  14.         {
  15.             string test = dateTimePicker1.Value.Date.ToShortDateString();
  16.             textBox1.Text = test;
  17.  
  18.             LoadActivity();
  19.         }
  20.  
  21.         public void InsertActivity(object sender, EventArgs e)
  22.         {
  23.             string activityString = textBox1.Text;
  24.             using (connection = new SqlConnection(connectionString))
  25.             {  
  26.                 SqlCommand command = new SqlCommand("INSERT INTO Activity VALUES('" + activityString + "')", connection);
  27.                 command.Connection.Open();
  28.                 command.ExecuteNonQuery();
  29.             }
  30.         }
  31.  
  32.         public void LoadActivity()
  33.         {
  34.             using (connection = new SqlConnection(connectionString))
  35.             {
  36.                 SqlCommand command = new SqlCommand("SELECT Activity FROM Planner", connection);
  37.                 command.Connection.Open();
  38.                 //SqlDataReader reader = command.ExecuteReader();
  39.                 //textBox1.Text = reader.GetString(0);
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment