VS2010中水晶报表引用mysql数据库中表单  怎么弄

解决方案 »

  1.   

     读取mysql数据到数据集,水晶报表绑定数据集
      

  2.   

    Pull或者Push
    Pull直接在水晶报表设计时设置好数据库连接的参数;
    Push则是先获取DataSet,然后再推给水晶报表。连接数据库的DEMO MySQLConnection conn = null;            conn = new MySQLConnection(new MySQLConnectionString("localhost", "inv", "root", "831025").AsString);            conn.Open();
                MySQLCommand commn = new MySQLCommand("set names gb2312", conn);            commn.ExecuteNonQuery();
                string sql = "select * from exchange ";            MySQLDataAdapter mda = new MySQLDataAdapter(sql, conn);
                DataSet ds = new DataSet();            mda.Fill(ds, "table1");
                this.dataGrid1.DataSource = ds.Tables["table1"];            conn.Close();
    水晶报表大全