WindowsForm C#上的水晶报告2008
错误:对象引用未设置为对象的实例。
如何修复它?
string appConn = ConfigurationManager.ConnectionStrings["connDB"].ConnectionString;
private void button5_Click(object sender, EventArgs e)
{
SqlConnection objConn = new SqlConnection();
SqlCommand objCmd = new SqlCommand();
SqlDataAdapter dtAdapter = new SqlDataAdapter();
DataSet ds = new DataSet();
DataTable dt;
string strSQL;
strSQL = "SELECT * FROM filesTA WHERE ChkDate = '" + dateTimePicker2.Value.ToString("yyyy-MM-dd") + "'";
objConn.ConnectionString = appConn;
var _with1 = objCmd;
_with1.Connection = objConn;
_with1.CommandText = strSQL;
_with1.CommandType = CommandType.Text;
dtAdapter.SelectCommand = objCmd;
dtAdapter.Fill(ds, "myDataTable");
dt = ds.Tables[0];
dtAdapter = null;
objConn.Close();
objConn = null;
ReportDocument rpt = new ReportDocument();
rpt.Load(System.Web.HttpContext.Current.Server.MapPath("Report\\CrystalReport1.rpt")); <<< Error
rpt.SetDataSource(dt);
this.crystalReportViewer1.ReportSource = rpt;
this.crystalReportViewer1.Refresh();
}
请帮帮我。谢谢你的时间。:)