0

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); }
1

1 Answer 1

1

you can find useful information in following link

http://www.mindstick.com/Articles/13169999-ef3b-496c-b502-caef973c3bb2/?Using%20ReportViewer%20in%20WinForms%20C

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.