我已经开始使用Crystal Reports创建报告。我能够使用dataset和sql显示所有内容,除了自动行编号。
这是我的代码:
SqlConnection cnn;
string connectionString = null;
string sql = null;
connectionString = "data source=Kim; initial catalog=DBO;user id=sa; password=passw0rd";
cnn = new SqlConnection(connectionString);
cnn.Open();
sql = "select Name as DataColumn1, Age as DataColumn2, from tbl1";
SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
cnn.Close();
DataSet2 ds = new DataSet2();
dscmd.Fill(ds, "DataTable2");
CrystalReport1 objRpt = new CrystalReport1 ();
objRpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = objRpt;
CrystalReportViewer1.RefreshReport();
报告的结果如下:
No Name Age
Kim 22
Ian 29
Aris 27
需要像这样显示报告:
No Name Age
1 Kim 22
2 Ian 29
3 Aris 27
你能给我提供如何添加行号的想法吗?