PDA

View Full Version : خطا در گزارش گیری در سی شارپ



ahmad000012
سه شنبه 20 دی 1390, 14:04 عصر
مشکل کد زیر چیه خطا میده


private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ReportDocument rd = new ReportDocument();
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
////
string cs = @"Server=localhost;Database=LIBRARY;integrated security=true;";
con.ConnectionString = cs;
con.Open();
/////
string sql;
switch (comboBox1.Text)
{
case "کتاب":
rd.FileName = "BookReport.rpt";

sql = "select * from book";

//

//cmd.CommandText = sql;
da.SelectCommand = cmd;
da.Fill(dt);


rd.SetDataSource(dt);
crystalReportViewer1.ReportSource = rd;
crystalReportViewer1.Show();
break;

}

con.Close();
}


ا