lgriess 0 Light Poster

This seems to be the appropriate thread to post my problem in:

I'm also trying to bind to a ReportViewer object, however I'm not binding a stored procedure but dynamic sql that selects <dynamic columns> from <dynamic views or tables>

nice huh? My boss has fallen in love with the front end on Microsoft Dynamics and issued a task for me to develop the same type of front end to our reports (which he likes to call reports but are really just about a hundred views and tables) he expects me to use the ReportViewer object because he loves this thing (I, myself hate it). I am therefore, forced to try to use ReportViewer with absolutely no developed rdl's since all I have is dynamic sql that runs against views or tables. I'm also developing in C# (my boss's favorite, again not mine). Anyway here is my source as it is:

    char[] endlim = { ',' };
    String strItem = String.Empty;
    String sqlStmt = String.Empty;
    int x = 0;
    // Setup Connection string
    cnstr = "server=serverIP;user=mylogin;password=mypassword;"
    + "database=db;";

    // Create a new Sql Connection
    SqlConnection cn = new SqlConnection(cnstr);

    //Create the DataSet
    ds = new DataSet("ds");

    sqlStmt = "Select ";
    //string querystring = "EmployeeReportViewer.aspx?ViewOrTable=" + ReportList.SelectedValue.ToString();

    foreach (ListItem listItem in ColumnListBox.Items)
    {
        if (listItem.Selected)
        {
            strItem = listItem.ToString();
            sqlStmt += strItem + ", ";
        }
    }
    sqlStmt = sqlStmt.Trim();
    sqlStmt = sqlStmt.TrimEnd(endlim);

    sqlStmt += " FROM " + ReportList.SelectedValue.ToString();

     SqlDataAdapter da = new SqlDataAdapter(sqlStmt, cn);

    // Fill the Data Adapter
    da.Fill(ds);
    DsRpt = Microsoft.Reporting.WebForms.ReportDataSource();
    DsRpt.Name = "Test";
    ReportViewer1.LocalReport.DataSources.Clear();
    //ReportViewer1.LocalReport.DataSources.Add(ds);

}

How in the h double hockey sticks can I create an RDL on the fly, with no defined columns or ReportDataSource?

Thanks anybody in advance.

Dean