public Otchet()
{
InitializeComponent();
LoadData2();
}
private void LoadData2()
{
string connectString = "Data Source=PC\\SQLEXPRESS;Initial Catalog=ACCORDA;Integrated Security=True";
SqlConnection myConnection = new SqlConnection(connectString);
myConnection.Open();
string query = " SELECT op.Summa, dg.Data_Zakluchenija" +
" FROM Dogovor AS dg " +
"JOIN Oplata AS op ON op.id_dogovor = dg.id_dogovor";
SqlCommand command2 = new SqlCommand(query, myConnection);
SqlDataReader reader2 = command2.ExecuteReader();
List<string[]> data = new List<string[]>();
while (reader2.Read())
{
data.Add(new string[2]);
data[data.Count - 1][0] = reader2[0].ToString();
data[data.Count - 1][1] = reader2[1].ToString();
}
reader2.Close();
myConnection.Close();
foreach (string[] s in data)
dataGridView2.Rows.Add(s);
}
private void button1_Click(object sender, EventArgs e)
{
}
DataTable rezult = new DataTable();
//Запрашиваем ответ в виде таблицы
MySqlDataAdapter da = new MySqlDataAdapter(query, myConnection);
da.Fill(rezult );
//Показываем данные на гриде
dataGridView2.DataSource = rezult;
//Создаем команду фильтра
string filter = "Convert([Data_Zakluchenija],'System.String') Like '%" + textBoxDate.Text+ "%'";
//Фильтруем грид по введенному тексту
(dataGridView2.DataSource as DataTable).DefaultView.RowFilter = com;