Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I want to do something like this:

 

 

       'create a dataset and a table
       Dim ds As New DataSet
       ds.Tables.Add("TestTable")
       ds.Tables("TestTable").Columns.Add("Names", System.Type.GetType("System.String"))

       'create a test row
       Dim TestRow As DataRow = ds.Tables("TestTable").NewRow
       TestRow.Item("Names") = "hello world"

       ds.Tables("TestTable").Rows.Add(TestRow)

       'attach dataset to report
       Dim dsname As String = "Dataset1"
       Dim rs As New Microsoft.Reporting.WinForms.ReportDataSource(dsname, ds.Tables("TestTable"))
       ReportViewer1.LocalReport.DataSources.Add(rs)

       'attach dataset to table on report
       ReportViewer1.LocalReport. '???

 

However I get this error:

The table �table1� is in the report body but the report has no data set.  Data regions are not allowed in reports without datasets.

 

There is no way for me to attach the dataset at design time, because it is not yet created! Is there a way around this? Also notice the last line is not complete in the code - how do you actually assign the dataset to the table on the report?

 

Thanks!

 

Dave

Posted

The only thing I could think of was to actually save the table to a database and setup the Table control's query to get the data from that data base. That seems really goofy though if the data is never to be used again, no?

 

Dave

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...