you can find useful information in following link
How to display data from Sql Database in table in report viewer
-
11-06-2023 - |
質問
I already display data to a DataGridView in my form with these codes, now I want to display that in a report viewer. How can I do this ?
//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); }
解決
所属していません StackOverflow