By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,307 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,307 IT Pros & Developers. It's quick & easy.

Web Application Project - ReportViewer Control

P: n/a
AG
I am trying to use a ReportViewer control in a VS 2005 web application
project (not Website project).
When I try to create a new report (local), I can't seem to find any method
to create a datasource. I would like to use an existing class object.
The examples I have found state that the class should be in the App_Code
folder. However a WAP does not have an App_Code folder.

Is there any way to specify a datasource for a local report in a WAP, or
must all reports be remote?

Thanks,

--

AG
Email: discuss at adhdata dot com
Aug 20 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hi AG,

From your description, you're wondering how to supply the DataSource for
the webform reportviewer control in an ASP.NET Web Application Project,
correct?

Based on my understanding, for webform reportviewer, you can supply the
datasource through the following means:

1) if you use the .NET built-in typed DataSet/TableAdpater components, you
can simply add a new typed DataSet(with TableAdapter) and the DataSet class
will appear in the VS 2005 ide's "Website Datasource" window. You can drag
the certain table's properties(columsn) onto the client report(rdlc)'s
design surface.

#Walkthrough: Using a Database Data Source with the ReportViewer Web Server
Control in Local Processing Mode
http://msdn2.microsoft.com/en-us/lib...23(VS.80).aspx

#the DataSet approach will work in both website project and Web Application
Project.

2) Or if you're using some custom class(which return the DataTable or
typedDataTable ), it seems the built-in "WebSite Data Source" windows can
not display it at design-time. One way to workaround it is as below:

1. In the SmartTag for the Report Viewer control, click Choose Data Source.

2. In the Choose Data Sources dialog, click inside the Data Source Instance
column and choose New Data Source.

3. Choose Object in the list of data sources.

4. In the Choose your business object combo-box, you should already see the
name of the Table Adapter that your report will use when it pulls
data...choose it. Or if you do not see your custom class, uncheck the "show
only data components" option so that all businesss classes will be availale
in the list:

5. Finish off the wizard...you now should be in good shape.

Or you can also manually select to use a custom class in aspx template:
============================
<rsweb:ReportViewer ID="ReportViewer2" runat="server" >
<LocalReport ReportPath="ClientReport1.rdlc">
<DataSources>
<rsweb:ReportDataSource
DataSourceId="ObjectDataSource2" Name="DataSet1_rpt_table" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
SelectMethod="GetDataTable"

TypeName="WAPTestProj.MyDataSourceClass"></asp:ObjectDataSource>
=============================

Here the "WAPTestProj.MyDataSourceClass" is a custom class as below:

===========

public class MyDataSourceClass
{
public DataSet1.rpt_tableDataTable GetDataTable()
{
DataSet1TableAdapters.rpt_tableTableAdapter ta = new
DataSet1TableAdapters.rpt_tableTableAdapter();

DataSet1.rpt_tableDataTable table = new
DataSet1.rpt_tableDataTable() ;

ta.Fill(table);

return table;
}
}
==================

In addition, you can also programmatically create and add datasource for
ReportViewer control. Here is a web forum thread discuss on this:

http://forums.microsoft.com/MSDN/Sho...70944&SiteID=1

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Aug 20 '07 #2

P: n/a
Thanks for your reply AG,

So your main concern is to view and use the custom datasource objects when
author the client report(RDLC) file, correct?

After some further research, I did found some existing problem about the
"Website Data Sources" windows which can not correctly display Business
object classes. And there is also some community members submit bug
requests on the public connect site(which has been recorded as an internal
bug entry):

#114670. Business Object Website Data Sources vanish when working with
RDLC
https://connect.microsoft.com/Visual....aspx?Feedback
ID=114670

So far I found that one of the workaround in the above url can helps us
some on this issue. As one member mentioned, if your business class's
method(which return the data records that will be bound to report data
region) will return an List(or Array) type object, it can be recognized and
displayed in the WebSite datasource window. I've tested in a Web
Application Project and it does work. For your scenario, you can try add a
method that return an List or Array of the certain data object class and
use it to author the report. How do you think?

Here is a test class I used which can be display in "website data sources"
window. BTW, I put it in a class library project:

===========
namespace ClassLib
{
public class MyDataSource
{

public List<EmployeeGetEmployees()
{
return new List<Employee>();
}
}

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public class Employee
{
private int _id;
private string _name;

public int ID
{
get { return _id; }
set { _id = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
=======================

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.



Aug 23 '07 #3

P: n/a
AG
Thanks Steven,

Yes, I see that 'List(of object)' is recognized.
My classes already return datatables, but I have not found a simple method
to convert a datatable or dataview to a list(of object) or list(of array).

Is there such a method?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Z9**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,

So your main concern is to view and use the custom datasource objects when
author the client report(RDLC) file, correct?

After some further research, I did found some existing problem about the
"Website Data Sources" windows which can not correctly display Business
object classes. And there is also some community members submit bug
requests on the public connect site(which has been recorded as an internal
bug entry):

#114670. Business Object Website Data Sources vanish when working with
RDLC
https://connect.microsoft.com/Visual....aspx?Feedback
ID=114670

So far I found that one of the workaround in the above url can helps us
some on this issue. As one member mentioned, if your business class's
method(which return the data records that will be bound to report data
region) will return an List(or Array) type object, it can be recognized
and
displayed in the WebSite datasource window. I've tested in a Web
Application Project and it does work. For your scenario, you can try add
a
method that return an List or Array of the certain data object class and
use it to author the report. How do you think?

Here is a test class I used which can be display in "website data sources"
window. BTW, I put it in a class library project:

===========
namespace ClassLib
{
public class MyDataSource
{

public List<EmployeeGetEmployees()
{
return new List<Employee>();
}
}

[System.Diagnostics.DebuggerNonUserCodeAttribute()]
public class Employee
{
private int _id;
private string _name;

public int ID
{
get { return _id; }
set { _id = value; }
}

public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
=======================

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.



Aug 23 '07 #4

P: n/a
Thanks for your followup AG,

So in your scenario, those Business class has already been well defined and
only return DataTable, dataset objects, right?

I've performed some further research and I suggest you consider the
following workaround:

** You can still keep the original business class's methods that return
DataTable, however, you can add a new method which return the typed DataRow
array. e.g. (the "GetDataRecords" method in the below class)

===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

return table;
}

public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

TDS.rpt_tableRow[] rows = new TDS.rpt_tableRow[table.Rows.Count];

table.Rows.CopyTo(rows, 0);

return rows;
}
}
=======================
** Thus, at development time, you can see the class and design the report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Aug 24 '07 #5

P: n/a
AG
Thanks Steven,

This looks promising, but I am having some trouble understanding it.
Could you please repeat it in VB and explain the origin of the object
sources (rpt_tableTableAdapter, etc) a bit more.
I have looked at help for table adapters and the examples are similar, but
still confusing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9T***************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your followup AG,

So in your scenario, those Business class has already been well defined
and
only return DataTable, dataset objects, right?

I've performed some further research and I suggest you consider the
following workaround:

** You can still keep the original business class's methods that return
DataTable, however, you can add a new method which return the typed
DataRow
array. e.g. (the "GetDataRecords" method in the below class)

===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

return table;
}

public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

TDS.rpt_tableRow[] rows = new
TDS.rpt_tableRow[table.Rows.Count];

table.Rows.CopyTo(rows, 0);

return rows;
}
}
=======================
** Thus, at development time, you can see the class and design the report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


Aug 24 '07 #6

P: n/a
Thanks for your reply AG,

Sorry that I haven't noticed you're using VB.NET.

Here is a VB.NET code snippet demonstrate some on this:

#in the following class, suppose GetDataTable() is the originally
function which directly return the TypedDataTable, now you can add a new
function that return the array of "TypedDataRow", like the "GetDataRecords"
function:
===============
Public Class MyDataSource

Public Function GetDataTable() As SimpleDS.UsersDataTable

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")
Return dt

End Function
Public Function GetDataRecords() As SimpleDS.UsersRow()

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")

Dim rows() As SimpleDS.UsersRow
ReDim rows(dt.Rows.Count)

dt.Rows.CopyTo(rows, 0)

Return rows
End Function
End Class
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
References: <#m**************@TK2MSFTNGP02.phx.gbl>
<OH**************@TK2MSFTNGHUB02.phx.gbl>
<uL**************@TK2MSFTNGP05.phx.gbl>
<Z9**************@TK2MSFTNGHUB02.phx.gbl>
<ON*************@TK2MSFTNGP06.phx.gbl>
<9T*************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Web Application Project - ReportViewer Control
Date: Fri, 24 Aug 2007 11:29:16 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Message-ID: <uC**************@TK2MSFTNGP04.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: ool-44c55ef0.dyn.optonline.net 68.197.94.240
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP04.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:39678
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks Steven,

This looks promising, but I am having some trouble understanding it.
Could you please repeat it in VB and explain the origin of the object
sources (rpt_tableTableAdapter, etc) a bit more.
I have looked at help for table adapters and the examples are similar, but
still confusing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9T***************@TK2MSFTNGHUB02.phx.gbl.. .
>Thanks for your followup AG,

So in your scenario, those Business class has already been well defined
and
only return DataTable, dataset objects, right?

I've performed some further research and I suggest you consider the
following workaround:

** You can still keep the original business class's methods that return
DataTable, however, you can add a new method which return the typed
DataRow
array. e.g. (the "GetDataRecords" method in the below class)

===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

return table;
}

public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

TDS.rpt_tableRow[] rows = new
TDS.rpt_tableRow[table.Rows.Count];

table.Rows.CopyTo(rows, 0);

return rows;
}
}
=======================
** Thus, at development time, you can see the class and design the report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.



Aug 27 '07 #7

P: n/a
AG
Thanks Steven,

Now I see where my problem lies.
My class is returning an un-typed datatable which is generated from a stored
procedure.
Can you point me so an example of creating a typed-datatable from an untyped
one?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Vm**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,

Sorry that I haven't noticed you're using VB.NET.

Here is a VB.NET code snippet demonstrate some on this:

#in the following class, suppose GetDataTable() is the originally
function which directly return the TypedDataTable, now you can add a new
function that return the array of "TypedDataRow", like the
"GetDataRecords"
function:
===============
Public Class MyDataSource

Public Function GetDataTable() As SimpleDS.UsersDataTable

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")
Return dt

End Function
Public Function GetDataRecords() As SimpleDS.UsersRow()

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")

Dim rows() As SimpleDS.UsersRow
ReDim rows(dt.Rows.Count)

dt.Rows.CopyTo(rows, 0)

Return rows
End Function
End Class
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
References: <#m**************@TK2MSFTNGP02.phx.gbl>
<OH**************@TK2MSFTNGHUB02.phx.gbl>
<uL**************@TK2MSFTNGP05.phx.gbl>
<Z9**************@TK2MSFTNGHUB02.phx.gbl>
<ON*************@TK2MSFTNGP06.phx.gbl>
<9T*************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: Web Application Project - ReportViewer Control
Date: Fri, 24 Aug 2007 11:29:16 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Message-ID: <uC**************@TK2MSFTNGP04.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: ool-44c55ef0.dyn.optonline.net 68.197.94.240
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP04.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:39678
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks Steven,

This looks promising, but I am having some trouble understanding it.
Could you please repeat it in VB and explain the origin of the object
sources (rpt_tableTableAdapter, etc) a bit more.
I have looked at help for table adapters and the examples are similar, but
still confusing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9T***************@TK2MSFTNGHUB02.phx.gbl. ..
>>Thanks for your followup AG,

So in your scenario, those Business class has already been well defined
and
only return DataTable, dataset objects, right?

I've performed some further research and I suggest you consider the
following workaround:

** You can still keep the original business class's methods that return
DataTable, however, you can add a new method which return the typed
DataRow
array. e.g. (the "GetDataRecords" method in the below class)

===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

return table;
}

public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

TDS.rpt_tableRow[] rows = new
TDS.rpt_tableRow[table.Rows.Count];

table.Rows.CopyTo(rows, 0);

return rows;
}
}
=======================
** Thus, at development time, you can see the class and design the
report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.




Aug 29 '07 #8

P: n/a
Thanks for your reply AG,

Now, I've seen the main problem here, your datatable are untyped. This does
be a big problem as untyped DataTable do not have strong-typed properties
that can be recognized by the design-time DataSource window.

So far I think you may consider the following approach:

** use code to write out the XML Schema for your untyped dataset/datatable,
here is a demo code snippet to do this:
=========
private void button1_Click(object sender, EventArgs e)
{

DataSet ds = new DataSet("myds");
DataTable dt = new DataTable("tb1");
dt.Columns.Add("id", typeof(long));
dt.Columns.Add("name", typeof(string));
dt.PrimaryKey = new DataColumn[]{dt.Columns["id"]};

dt.Rows.Add(1, "item1");
dt.Rows.Add(2, "item2");

dt.WriteXmlSchema("dt_scheme.xsd");

}
}
================

**after that, add the output xsd file(generarted above) into your project
and let the VS IDE create a typed dataset/datatable for you.

** use the new generated type dataset/datatable type in your business class
to create the fake method(be used by datasource window)

How do you think? If you have any further questions on this, please feel
free to let me know.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
>
Thanks Steven,

Now I see where my problem lies.
My class is returning an un-typed datatable which is generated from a
stored
>procedure.
Can you point me so an example of creating a typed-datatable from an
untyped
>one?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Vm**************@TK2MSFTNGHUB02.phx.gbl...
>Thanks for your reply AG,

Sorry that I haven't noticed you're using VB.NET.

Here is a VB.NET code snippet demonstrate some on this:

#in the following class, suppose GetDataTable() is the originally
function which directly return the TypedDataTable, now you can add a new
function that return the array of "TypedDataRow", like the
"GetDataRecords"
function:
===============
Public Class MyDataSource

Public Function GetDataTable() As SimpleDS.UsersDataTable

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")
Return dt

End Function
Public Function GetDataRecords() As SimpleDS.UsersRow()

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")

Dim rows() As SimpleDS.UsersRow
ReDim rows(dt.Rows.Count)

dt.Rows.CopyTo(rows, 0)

Return rows
End Function
End Class
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
References: <#m**************@TK2MSFTNGP02.phx.gbl>
<OH**************@TK2MSFTNGHUB02.phx.gbl>
<uL**************@TK2MSFTNGP05.phx.gbl>
<Z9**************@TK2MSFTNGHUB02.phx.gbl>
<ON*************@TK2MSFTNGP06.phx.gbl>
<9T*************@TK2MSFTNGHUB02.phx.gbl>
>>>Subject: Re: Web Application Project - ReportViewer Control
Date: Fri, 24 Aug 2007 11:29:16 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Message-ID: <uC**************@TK2MSFTNGP04.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: ool-44c55ef0.dyn.optonline.net 68.197.94.240
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP04.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:3967 8
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks Steven,

This looks promising, but I am having some trouble understanding it.
Could you please repeat it in VB and explain the origin of the object
sources (rpt_tableTableAdapter, etc) a bit more.
I have looked at help for table adapters and the examples are similar,
but
>>>still confusing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9T***************@TK2MSFTNGHUB02.phx.gbl.. .
Thanks for your followup AG,

So in your scenario, those Business class has already been well defined
and
only return DataTable, dataset objects, right?

I've performed some further research and I suggest you consider the
following workaround:

** You can still keep the original business class's methods that return
DataTable, however, you can add a new method which return the typed
DataRow
array. e.g. (the "GetDataRecords" method in the below class)

===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

return table;
}

public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();

TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();

ta.Fill(table);

TDS.rpt_tableRow[] rows = new
TDS.rpt_tableRow[table.Rows.Count];

table.Rows.CopyTo(rows, 0);

return rows;
}
}
=======================
** Thus, at development time, you can see the class and design the
report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)

How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.




Aug 31 '07 #9

P: n/a
AG
Steven,

A columns in a datatable derived from a SQL strored procedure contain the
schema info, so I don't understand why the datatable would not be considered
typed.

Anyway, are you saying that the only way to create a typed datatable, is to
create a separate xsd file and the loop through all my rows and add them to
the new datatable??

That seems very inefficient.

I might be better off creating a separate reports project and deploy to the
report server and use remote processing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:C9**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,

Now, I've seen the main problem here, your datatable are untyped. This
does
be a big problem as untyped DataTable do not have strong-typed properties
that can be recognized by the design-time DataSource window.

So far I think you may consider the following approach:

** use code to write out the XML Schema for your untyped
dataset/datatable,
here is a demo code snippet to do this:
=========
private void button1_Click(object sender, EventArgs e)
{

DataSet ds = new DataSet("myds");
DataTable dt = new DataTable("tb1");
dt.Columns.Add("id", typeof(long));
dt.Columns.Add("name", typeof(string));
dt.PrimaryKey = new DataColumn[]{dt.Columns["id"]};

dt.Rows.Add(1, "item1");
dt.Rows.Add(2, "item2");

dt.WriteXmlSchema("dt_scheme.xsd");

}
}
================

**after that, add the output xsd file(generarted above) into your project
and let the VS IDE create a typed dataset/datatable for you.

** use the new generated type dataset/datatable type in your business
class
to create the fake method(be used by datasource window)

How do you think? If you have any further questions on this, please feel
free to let me know.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
>>
Thanks Steven,

Now I see where my problem lies.
My class is returning an un-typed datatable which is generated from a
stored
>>procedure.
Can you point me so an example of creating a typed-datatable from an
untyped
>>one?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Vm**************@TK2MSFTNGHUB02.phx.gbl.. .
>>Thanks for your reply AG,

Sorry that I haven't noticed you're using VB.NET.

Here is a VB.NET code snippet demonstrate some on this:

#in the following class, suppose GetDataTable() is the originally
function which directly return the TypedDataTable, now you can add a new
function that return the array of "TypedDataRow", like the
"GetDataRecords"
function:
===============
Public Class MyDataSource

Public Function GetDataTable() As SimpleDS.UsersDataTable

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")
Return dt

End Function
Public Function GetDataRecords() As SimpleDS.UsersRow()

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")

Dim rows() As SimpleDS.UsersRow
ReDim rows(dt.Rows.Count)

dt.Rows.CopyTo(rows, 0)

Return rows
End Function
End Class
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
References: <#m**************@TK2MSFTNGP02.phx.gbl>
<OH**************@TK2MSFTNGHUB02.phx.gbl>
<uL**************@TK2MSFTNGP05.phx.gbl>
<Z9**************@TK2MSFTNGHUB02.phx.gbl>
<ON*************@TK2MSFTNGP06.phx.gbl>
<9T*************@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: Web Application Project - ReportViewer Control
Date: Fri, 24 Aug 2007 11:29:16 -0400
Lines: 87
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Message-ID: <uC**************@TK2MSFTNGP04.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: ool-44c55ef0.dyn.optonline.net 68.197.94.240
Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP04.phx.gbl
Xref: TK2MSFTNGHUB02.phx.gbl
microsoft.public.dotnet.framework.aspnet:396 78
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Thanks Steven,

This looks promising, but I am having some trouble understanding it.
Could you please repeat it in VB and explain the origin of the object
sources (rpt_tableTableAdapter, etc) a bit more.
I have looked at help for table adapters and the examples are similar,
but
>>>>still confusing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:9T***************@TK2MSFTNGHUB02.phx.gbl. ..
Thanks for your followup AG,
>
So in your scenario, those Business class has already been well
defined
and
only return DataTable, dataset objects, right?
>
I've performed some further research and I suggest you consider the
following workaround:
>
** You can still keep the original business class's methods that
return
DataTable, however, you can add a new method which return the typed
DataRow
array. e.g. (the "GetDataRecords" method in the below class)
>
===========================
public class MyDataSource
{
public TDS.rpt_tableDataTable GetDataTable()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();
>
TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();
>
ta.Fill(table);
>
return table;
}
>
public TDS.rpt_tableRow[] GetDataRecords()
{
TDSTableAdapters.rpt_tableTableAdapter ta = new
TDSTableAdapters.rpt_tableTableAdapter();
>
TDS.rpt_tableDataTable table = new TDS.rpt_tableDataTable();
>
ta.Fill(table);
>
TDS.rpt_tableRow[] rows = new
TDS.rpt_tableRow[table.Rows.Count];
>
table.Rows.CopyTo(rows, 0);
>
return rows;
}
>
>
}
=======================
>
>
** Thus, at development time, you can see the class and design the
report
by the typedDataRow's properties in "Website data source" window. At
runtime, you can change the datasource back to use the original
method(which return DataTable)
>
How do you think?
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
>
>




Sep 2 '07 #10

P: n/a
Thanks for your followup AG,

The "strong typed" I mentioned here means the component class much have a
strong property to repesent a certain table column. For example, the typed
DataTable will contains many properties such as:

TypedDataTableRow.Column1, TypedDataTableRow.Column2 to supply the
database fields

However, for untyped datatable, you have to use DataRow["columnname"] to
access them. Visual Studio IDE's report datasource can only reflect
strong-typed properties, that's why untyped DataSet/DataTable can not work
here.

For creating a separate typed DataTable, I just use it to design the rdlc
report at design-time, after you finished the RDLC report design, you can
switch to use the original untyped one. So far this is a workaround
approach I can get.

Also, for the limitation here, it really make the client report designing
quite inconvenient, I will recommend you submit this issue to the feedback
center so as to inform the dev team. We really appreciate your feedback on
this:

https://connect.microsoft.com/feedba...&wa=wsignin1.0

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
>
Steven,

A columns in a datatable derived from a SQL strored procedure contain the
schema info, so I don't understand why the datatable would not be
considered
>typed.

Anyway, are you saying that the only way to create a typed datatable, is
to
>create a separate xsd file and the loop through all my rows and add them
to
>the new datatable??

That seems very inefficient.

I might be better off creating a separate reports project and deploy to
the
>report server and use remote processing.

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:C9**************@TK2MSFTNGHUB02.phx.gbl...
>Thanks for your reply AG,

Now, I've seen the main problem here, your datatable are untyped. This
does
be a big problem as untyped DataTable do not have strong-typed properties
that can be recognized by the design-time DataSource window.

So far I think you may consider the following approach:

** use code to write out the XML Schema for your untyped
dataset/datatable,
here is a demo code snippet to do this:
=========
private void button1_Click(object sender, EventArgs e)
{

DataSet ds = new DataSet("myds");
DataTable dt = new DataTable("tb1");
dt.Columns.Add("id", typeof(long));
dt.Columns.Add("name", typeof(string));
dt.PrimaryKey = new DataColumn[]{dt.Columns["id"]};

dt.Rows.Add(1, "item1");
dt.Rows.Add(2, "item2");

dt.WriteXmlSchema("dt_scheme.xsd");

}
}
================

**after that, add the output xsd file(generarted above) into your
project
>and let the VS IDE create a typed dataset/datatable for you.

** use the new generated type dataset/datatable type in your business
class
to create the fake method(be used by datasource window)

How do you think? If you have any further questions on this, please feel
free to let me know.
Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>>>Reply-To: "AG" <NO**********@newsgroups.nospam>
From: "AG" <NO**********@newsgroups.nospam>
>>>
Thanks Steven,

Now I see where my problem lies.
My class is returning an un-typed datatable which is generated from a
stored
>>>procedure.
Can you point me so an example of creating a typed-datatable from an
untyped
>>>one?

--

AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:Vm**************@TK2MSFTNGHUB02.phx.gbl. ..
Thanks for your reply AG,

Sorry that I haven't noticed you're using VB.NET.

Here is a VB.NET code snippet demonstrate some on this:

#in the following class, suppose GetDataTable() is the originally
function which directly return the TypedDataTable, now you can add a
new
>>>function that return the array of "TypedDataRow", like the
"GetDataRecords"
function:
===============
Public Class MyDataSource

Public Function GetDataTable() As SimpleDS.UsersDataTable

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")
Return dt

End Function
Public Function GetDataRecords() As SimpleDS.UsersRow()

Dim dt As New SimpleDS.UsersDataTable
dt.Rows.Add(1, "name1", "email1")
dt.Rows.Add(2, "name2", "email2")

Dim rows() As SimpleDS.UsersRow
ReDim rows(dt.Rows.Count)

dt.Rows.CopyTo(rows, 0)

Return rows
End Function
End Class
==============

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
>Reply-To: "AG" <NO**********@newsgroups.nospam>
>From: "AG" <NO**********@newsgroups.nospam>
>References: <#m**************@TK2MSFTNGP02.phx.gbl>
<OH**************@TK2MSFTNGHUB02.phx.gbl>
<uL**************@TK2MSFTNGP05.phx.gbl>
<Z9**************@TK2MSFTNGHUB02.phx.gbl>
<ON*************@TK2MSFTNGP06.phx.gbl>
<9T*************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Web Application Project - ReportViewer Control
>Date: Fri, 24 Aug 2007 11:29:16 -0400
>Lines: 87
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
>X-RFC2646: Format=Flowed; Original
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
>Message-ID: <uC**************@TK2MSFTNGP04.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: ool-44c55ef0.dyn.optonline.net 68.197.94.240
>Path: TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TNGP04.phx.gbl
>Xref: TK2MSFTNGHUB02.phx.gbl
>microsoft.public.dotnet.framework.aspnet:3967 8
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>Thanks Steven,
>
>This looks promising, but I am having some trouble understanding it.
>Could you please repeat it in VB and explain the origin of the object
>sources (rpt_tableTableAdapter, etc) a bit more.
>I have looked at help for table adapters and the examples are similar,
but
>>>>>still confusing.
>
>--
>
>AG
>Email: discuss at adhdata dot com
>"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
>news:9T***************@TK2MSFTNGHUB02.phx.gbl ...
>Thanks for your followup AG,
>>
>So in your scenario, those Business class has already been well
>defined
>and
>only return DataTable, dataset objects, right?
>>
>I've performed some further research and I suggest you consider the
>following workaround:
>>
>** You can still keep the original business class's methods that
>return
>DataTable, however, you can add a new method which return the typed
>DataRow
>array. e.g. (the "GetDataRecords" method in the below class)
>>
>===========================
>public class MyDataSource
> {
> public TDS.rpt_tableDataTable GetDataTable()
> {
> TDSTableAdapters.rpt_tableTableAdapter ta = new
>TDSTableAdapters.rpt_tableTableAdapter();
>>
> TDS.rpt_tableDataTable table = new
TDS.rpt_tableDataTable();
>>>>>>
> ta.Fill(table);
>>
> return table;
> }
>>
> public TDS.rpt_tableRow[] GetDataRecords()
> {
> TDSTableAdapters.rpt_tableTableAdapter ta = new
>TDSTableAdapters.rpt_tableTableAdapter();
>>
> TDS.rpt_tableDataTable table = new
TDS.rpt_tableDataTable();
>>>>>>
> ta.Fill(table);
>>
> TDS.rpt_tableRow[] rows = new
>TDS.rpt_tableRow[table.Rows.Count];
>>
> table.Rows.CopyTo(rows, 0);
>>
> return rows;
> }
>>
>>
> }
>=======================
>>
>>
>** Thus, at development time, you can see the class and design the
>report
>by the typedDataRow's properties in "Website data source" window. At
>runtime, you can change the datasource back to use the original
>method(which return DataTable)
>>
>How do you think?
>>
>Sincerely,
>>
>Steven Cheng
>>
>Microsoft MSDN Online Support Lead
>>
>>
>This posting is provided "AS IS" with no warranties, and confers no
>rights.
>>
>>
>>
>>
>
>
>



Sep 3 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.