Results 1 to 3 of 3

Thread: [2008] Untyped vs strongely typed

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2008
    Posts
    21

    [2008] Untyped vs strongely typed

    Hi

    I have made a lot of search to know about the difference between untyped and strongelytyped dataset or untyped and strongelytyped classes but i didn't understand well the concept.
    can anyone give me a clear explanation about the difference?

    thanks

  2. #2
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: [2008] Untyped vs strongely typed

    Using a strongly typed data set will give you extended intellisence for your data set, and will do type conversion for you. Example

    Code:
    'generic dataset
    For Each row as DataRow in myDataSet.Tables("Table1").Rows
      Dim myString As String = CStr(row.Item("myString"))
    Next
    Code:
    'Strongly Typed dataset
    For Each row as myDataSet.Table1DataRow in myDataSet.Table1.Rows
      Dim myString As String = row.myString
    Next
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2008] Untyped vs strongely typed

    Each field in each row of each table in a typed DataSet is exposed via a property of a particular type. As such the compiler will do all the type checking for you and tell you at compile time if you're assigning a value of the wrong type to a field in a row.

    Each field in each row of each table in an untyped DataSet is exposed via the Item property and is type Object, because it has to able to accept any type of object. As such, you won't find out until run time if you've assigned a value of the wrong type to a field, when an exception is thrown.

    Note also that a typed DataSet creates TableAdapters for you, which are essentially a typed DataAdapter. All the SQL code and connection details are contained within the TableAdapter so you don't have to write the code yourself. Each TableAdapter is paired with a typed DataTable. The SQL code in the TableAdapter is matched to the schema of the DataTable so they are always used together.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width