Results 1 to 8 of 8

Thread: [RESOLVED] DataTable vs DataSet

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] DataTable vs DataSet

    Hi all,

    sorry if this is pretty basic but im a little confused about the releation between datasets and dataTables


    If i have a dataset the info i fill it with would be the Datatables? I assume i can fill a dataset with more than one DataTable


    if i need to manipulate the data i would do it from the datatable?

    If i am just given a dataset how would i tell how many datatables are in it ( if the above statements are true)


    Thanks

    Robert

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: DataTable vs DataSet

    a dataset can contain zero or more datatables. A datatable can contain zero or more datarows. A datarow can contain zero or more datacolumns.

    They all have a .Count property

    But a datatable can exist outside a dataset. A dataset is most usefull if 1) you want to relate multiple datatables to each other (vis dataRelations) or if 2) you simply just want to have all your datatables in one spot rather than in multiple variables.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: DataTable vs DataSet

    Quote Originally Posted by tg
    a dataset can contain zero or more datatables...
    No Sir, Dataset contains 1 DataTableCollection, which in turns contains zero or more Datatables, and so on.

    That's why you have to specify the index of DataTable when accessing a table inside DataSet.

    example.
    Code:
    DataSet ds = new DataSet();
    string item;
    item = ds.Tables["tablename"].Rows[rowindex][columnindex].ToString();
    Show Appreciation. Rate Posts.

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: DataTable vs DataSet

    now you're just splitting hairs..... and it doesn't have to be an index (which insinuates a numeric value) it can also be a Key/TableName (as shown in your example).

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: DataTable vs DataSet

    Even I was not completely right
    Show Appreciation. Rate Posts.

  6. #6

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: DataTable vs DataSet

    so if i am only useing one set of data that i dont need to releate to any other data i should just work in a datatable?

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: DataTable vs DataSet

    yeppers.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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

    Re: DataTable vs DataSet

    The other advantage of the DataSet class is that it inherits Component, which means it has design-time support. You can add a DataSet to a form in the designer but you cannot do the same with a DataTable. If you're not separating your data layer from your presentation layer then I'd suggest taking advantage of this fact so that you can set up data-binding at design time.
    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