Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void LoadData()
- {
- string connectString = "datasource=localhost;port=3306;Initial Catalog= 'Rebel';username=root;password=";
- MySqlConnection myConnection = new MySqlConnection(connectString);
- myConnection.Open();
- string query = "SELECT * FROM `Товары`";
- MySqlCommand command = new MySqlCommand(query, myConnection);
- MySqlDataReader reader = command.ExecuteReader();
- List<string[]> data = new List<string[]>();
- while (reader.Read())
- {
- data.Add(new string[4]);
- data[data.Count - 1][0] = reader[0].ToString();
- data[data.Count - 1][1] = reader[1].ToString();
- data[data.Count - 1][2] = reader[2].ToString();
- data[data.Count - 1][3] = reader[3].ToString();
- }
- reader.Close();
- myConnection.Close();
- foreach (string[] s in data)
- dataGridView1.Rows.Add(s);
- }
Add Comment
Please, Sign In to add comment