Click here to Skip to main content
15,944,959 members
Home / Discussions / C#
   

C#

 
AnswerRe: display solid square program Pin
Pete O'Hanlon2-May-07 0:58
mvePete O'Hanlon2-May-07 0:58 
AnswerRe: display solid square program Pin
Muammar©3-May-07 22:36
Muammar©3-May-07 22:36 
QuestionHow to make an object dynamically Pin
Karel841-May-07 22:29
Karel841-May-07 22:29 
AnswerRe: How to make an object dynamically Pin
Pete O'Hanlon1-May-07 22:47
mvePete O'Hanlon1-May-07 22:47 
AnswerRe: How to make an object dynamically Pin
LongRange.Shooter2-May-07 10:16
LongRange.Shooter2-May-07 10:16 
QuestionDatarow Array with foreach question Pin
Osrald1-May-07 21:58
Osrald1-May-07 21:58 
AnswerRe: Datarow Array with foreach question Pin
Venk2592-May-07 0:47
Venk2592-May-07 0:47 
QuestionHow to dynamically convert between Types? Pin
Subrahmanyam K1-May-07 21:39
Subrahmanyam K1-May-07 21:39 
Hi Friends,

Please help me for the below requirement.

Note:
Typed Datasets are considered for the requirement.
Here, LookupTableDataSet Typed Dataset consists of the Agency and Authority DataTables.

I have two methods as given below.

public Int32 GetRowsInTable(String tableName)<br />
        {<br />
            Int32 result = 0;<br />
<br />
                LookupTableDataSet ds = new LookupTableDataSet();<br />
<br />
                System.Data.DataTable dataTable = Fill(ds.Tables[tableName]);<br />
                result = dataTable.Rows.Count;<br />
<br />
                return result;<br />
        }<br />
<br />
<br />
      public LookupTableDataSet.AgencyDataTable Fill(LookupTableDataSet.AgencyDataTable dtAgency)<br />
        {<br />
                AgencyTableAdapter adapter = new AgencyTableAdapter();<br />
                adapter.Fill(dtAgency);<br />
                return dtAgency;<br />
        }<br />
<br />
        public LookupTableDataSet.AuthorityDataTable Fill(LookupTableDataSet.AuthorityDataTable dtAuthority)<br />
        {<br />
                AuthorityTableAdapter adapter = new AuthorityTableAdapter();<br />
                adapter.Fill(dtAuthority);<br />
                return dtAuthority;<br />
        }


1. GetRowsInTable(String tableName) should return the row count for the table name sent as the parameter.
2. Fill() method is overloaded with different types of input parameters and return types.

My requirement is that I have to pass the table name as the parameter to the GetRowsInTable() method to get the rows count for the table.
As the Fill() method is overloaded with different types of input parameters how can I convert the input parameter to a specific type based on
the tablename which was sent as a parameter to the GetRowsInTable() method?

When I call the fill method as Fill(ds.Tables[tableName]), A System.Data.Dataset is being passed to the Fill() method where the fill method will accept only types
LookupTableDataSet.AgencyDataTable or LookupTableDataSet.AuthorityDataTable.

How can I dynamically convert the System.Data.DataSet to the required type to call the Fill() method.
Also, please suggest me on dynamically casting the return types of Fill() methods.

Statement throwing compilation errors were shown in Bold+Italic.

Thanks in advance.


Subrahmanyam K

AnswerRe: How to dynamically convert between Types? Pin
Christian Graus1-May-07 23:35
protectorChristian Graus1-May-07 23:35 
GeneralRe: How to dynamically convert between Types? Pin
Subrahmanyam K2-May-07 4:37
Subrahmanyam K2-May-07 4:37 
QuestionAuthenticating the Windows username and password Pin
Dotnetkanna1-May-07 20:56
Dotnetkanna1-May-07 20:56 
AnswerRe: Authenticating the Windows username and password Pin
stancrm1-May-07 22:32
stancrm1-May-07 22:32 
GeneralRe: Authenticating the Windows username and password Pin
Dotnetkanna1-May-07 23:59
Dotnetkanna1-May-07 23:59 
GeneralRe: Authenticating the Windows username and password Pin
stancrm2-May-07 0:17
stancrm2-May-07 0:17 
AnswerRe: Authenticating the Windows username and password Pin
Pete O'Hanlon2-May-07 0:56
mvePete O'Hanlon2-May-07 0:56 
QuestionEvents in web service.... Pin
Mandaar Kulkarni1-May-07 20:50
Mandaar Kulkarni1-May-07 20:50 
QuestionCross Thread Operation Pin
kraj991-May-07 19:53
kraj991-May-07 19:53 
AnswerRe: Cross Thread Operation Pin
Mandaar Kulkarni1-May-07 21:02
Mandaar Kulkarni1-May-07 21:02 
Questionhelp here... square program Pin
Missy Glory1-May-07 19:24
Missy Glory1-May-07 19:24 
AnswerRe: help here... square program Pin
stancrm1-May-07 19:40
stancrm1-May-07 19:40 
AnswerRe: help here... square program Pin
Michael1011-May-07 19:40
Michael1011-May-07 19:40 
AnswerRe: help here... square program Pin
Guffa1-May-07 22:27
Guffa1-May-07 22:27 
QuestionC# ASP.NET Printing Puzzle!! Pin
Michael1011-May-07 18:11
Michael1011-May-07 18:11 
AnswerRe: C# ASP.NET Printing Puzzle!! Pin
Christian Graus1-May-07 19:17
protectorChristian Graus1-May-07 19:17 
GeneralRe: C# ASP.NET Printing Puzzle!! Pin
Michael1011-May-07 19:38
Michael1011-May-07 19:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.