MySqlCommand cmd; // Получаем данные из таблицы testimony
cmd = con.CreateCommand();
cmd.CommandText = "SELECT Name FROM records";
con.Open();
List<string> array = new List<string>();
MySqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
array.Add(sdr.GetString(0));
}
con.Close();
MySqlCommand cmd_FillTestimony; // Получаем данные из таблицы testimony
cmd_FillTestimony = con.CreateCommand();
cmd_FillTestimony.CommandText = "SELECT * FROM testimony WHERE Name IN(@record1, @record2)";
for (int i = 0; i < array.Count(); i++)
{
cmd_FillTestimony.Parameters.AddWithValue("@record" + (i + 1), array[i]);
}
try
{
con.Open();
MySqlDataAdapter da_testimony = new MySqlDataAdapter(cmd_FillTestimony);
DataSet dataset_testimony = new DataSet();
da_testimony.Fill(dataset_testimony, "testimony");
report2.RegisterData(dataset_testimony.Tables["testimony"], "testimony");
(report2.Report.FindObject("Testimony_Data") as DataBand).DataSource = report2.GetDataSource("testimony");
report2.GetDataSource("testimony").Enabled = true;
con.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
report2.Show();
MySqlConnection con = new MySqlConnection(AppSetting.ConnectonString());
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter("SELECT * FROM patients WHERE id='" + MyListBox.SelectedValue + "';", con);
da.Fill(dt);
reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource rp = new ReportDataSource("DataSet1", dt);
reportViewer1.LocalReport.DataSources.Add(rp);
reportViewer1.RefreshReport();