Advertisement
AIwinter

sdafda

May 4th, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. /**public void RefreshTable()
  2. {
  3. string connectionString = "data source=localhost; initial catalog = owo; persist security info = True; Integrated Security = SSPI; ";
  4. //comboBox1.SelectedIndex == null ? comboBox1.SelectedIndex := 0 : string selectedTable = comboBox1.SelectedItem.ToString();
  5. //comboBox1.SelectedIndex = 0; / if (selectedTable) { selectedTable = 0; }
  6.  
  7. string selectedTable = comboBox1.SelectedItem.ToString();
  8. string sql = $"SELECT * FROM [{selectedTable} WHERE id < 0]";
  9. using (SqlConnection connection = new SqlConnection(connectionString))
  10. {
  11. connection.Open();
  12. // Создаем объект DataAdapter
  13. SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
  14. // Создаем объект Dataset
  15. DataSet ds = new DataSet();
  16. // Заполняем Dataset
  17. adapter.Fill(ds);
  18. // Отображаем данные
  19. dataGridView1.DataSource = ds.Tables[0];
  20. }
  21. }
  22.  
  23.  
  24.  
  25. public Add_Form()
  26. {
  27. InitializeComponent();
  28. }
  29.  
  30. private void refresh_button_Click(object sender, EventArgs e)
  31. {
  32. RefreshTable();
  33. }
  34.  
  35. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  36. {
  37. string selectedTable = comboBox1.SelectedItem.ToString();
  38. }**/
  39.  
  40. public Add_Form()
  41. {
  42. InitializeComponent();
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement