大家晚上好~~~~一个报表的问题,运行无误,但是运行后报表无显示~
CrystalReport1 objReceiptCrystalReport = new CrystalReport1(); //实例化报表
………………………………………………………………………………………………
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
crystalReportViewer1.ReportSource = objReceiptCrystalReport;
GetData("select * from 订货单");
}
protected void GetData(string selectCommand)
{
try
{
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "Data Source=XP-201112152206\\SQLEXPRESS;Initial catalog=某;Integrated Security=true";
cnn.Open();
dataAdapter = new SqlDataAdapter(selectCommand, cnn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds,"receipt");
objReceiptCrystalReport.SetDataSource(ds.Tables["receipt"]);
cnn.Close();
}
catch (SqlException)
{
MessageBox.Show("数据库异常!");
}
}
-----------------------------------
运行以后 报表里面是空白的 啥也没有 我确定数据库里有记录
谢大侠了~~~~~~~~~~~~~
------解决方案--------------------有些数据库的表要加[]
------解决方案--------------------ds.Tables[0].TableName = "receipt";
objReceiptCrystalReport.SetDataSource(ds);
看看行不