Advertisement
Guest User

Untitled

a guest
Aug 5th, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. private void InsertData_Click(object sender, EventArgs e)
  2. {
  3.  
  4. var textboxes = new List<TextBox>() {
  5. textBox1,
  6. textBox2,
  7. textBox3,
  8. textBox4,
  9. textBox5,
  10. textBox6,
  11. textBox7,
  12. textBox8,
  13. textBox9,
  14. textBox10,
  15. textBox11,
  16. textBox12,
  17. textBox13,
  18. textBox14,
  19. textBox15,
  20. textBox16,
  21. textBox17,
  22. textBox18,
  23. textBox19,
  24. textBox20
  25. };
  26. var labels = new List<Label>() {
  27. Date2,
  28. Date4,
  29. Date6,
  30. Date8,
  31. Date10,
  32. Date12,
  33. Date14,
  34. Date16,
  35. Date18,
  36. Date20
  37. };
  38.  
  39. SqlCeConnection connection = new SqlCeConnection(@"Data Source=C:UsersFluksikartoNDocumentsVisual Studio 2012ProjectsBuroFokiBuroFokiMainDB.sdf");
  40. connection.Open();
  41.  
  42. for (int i = 0; i < 10 ; i = i++)
  43. {
  44.  
  45. using (SqlCeCommand com = new SqlCeCommand("INSERT INTO TenOperations (EUR, Rate, BGN, Date) Values(@EUR, @Rate, @BGN, @Date)", connection))
  46. {
  47.  
  48.  
  49. com.Parameters.AddWithValue("@EUR", textboxes[i+1].Text.ToString());
  50. com.Parameters.AddWithValue("@Rate", EURbuy);
  51. com.Parameters.AddWithValue("@BGN", textboxes[i].Text.ToString());
  52. com.Parameters.AddWithValue("@Date", labels[i].Text.ToString());
  53.  
  54. com.ExecuteNonQuery();
  55.  
  56. }
  57. }
  58. connection.Close();
  59.  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement