我最近刚刚安装了 Visual Studio 2012,我的 Crystal 报表在 2010 中一切正常,但是当我将代码迁移到 2012 时,我无法显示任何内容。您能否检查一下这段代码是否缺少我的东西:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cnn;
string connectionString = null;
string sql = null;
connectionString = "data source=server; initial catalog=DBO;user id=sa; password= passw0rd";
cnn = new SqlConnection(connectionString);
cnn.Open();
sql = "select BadgeNo as DataColumn1,Name as DataColumn2, Section as DataColumn3 from Safety where ID = '24'";
SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
cnn.Close();
DataSet1 ds = new DataSet1();
dscmd.Fill(ds, "DataTable1");
ReportobjRpt = new Report1 ();
objRpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = objRpt;
CrystalReportViewer1.RefreshReport();
}
我正在使用数据集将数据从 SQL 服务器传输到水晶报表。请帮忙。谢谢你。