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
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" <
[email protected]>
From: "AG" <
[email protected]>
References: <#
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
<9TI5W#
[email protected]>
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: <
[email protected]>
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!TK2MSFTNGP04.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
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.