我已经使用这些代码在我的表单中向DataGridView显示数据,现在我想在报表查看器中显示它。我怎么能这样做?
//Fill DataGridView
try
{
MyDB db = new MyDB();//my connection string
string sql = "SELECT * FROM innoviceitem WHERE id='{0}'";
sql = string.Format(sql, id);//id is a public string that its value has been set
SqlDataAdapter sda = new SqlDataAdapter(sql, db.MyConn);
DataSet ds = new DataSet();
BindingSource bs = new BindingSource();
sda.Fill(ds);
bs.DataSource = ds.Tables[0].DefaultView;
datagridview1.DataSource = bs;
}
catch (Exception err) { MessageBox.Show(err.Message); }
答案 0 :(得分:1)