日期:2014-05-17 浏览次数:20991 次
private void Form1_Load(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection("Server=127.0.0.1;Initial Catalog=StuMgWeb;User Id=sa;Password=000000;"))
{
conn.Open();
using (SqlDataAdapter adpt = new SqlDataAdapter("select * from T_Student", conn))
{
DataSet ds = new DataSet();
adpt.Fill(ds);
string reportPath = Application.StartupPath + @"\CrystalReport1.rpt";
DataTable dt = ds.Tables[0];
//MessageBox.Show(dt.Rows.Count.ToString());
ReportDocument rd = new ReportDocument();
rd.Load(reportPath);
////List<T_Student> list = new List<T_Student>(dt.Rows.Count);
T_Student[] stus = new T_Student[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
T_Student stu = new T_Student();
stu.Name = (string)dt.Rows[i]["Name"];
stu.Birthday = dt.Rows[i]["Birthday"].ToString();
stus[i] = stu;
}
&