Solved

Difference between Fill and Return DataTable in VS 2005

Posted on 2007-04-05
2
692 Views
Last Modified: 2013-11-26
When you create a new dataset in Visual Studio 2005, the Table Adapter Configuration Wizard comes up.  It gives you three options:

Fill a DataTable
Return a DataTable
GenerateDBDirectMethods

What are the differences between these three--and especially the first two.  I've looked a bit online and haven't yet found a tutorial that makes enough sense.  Links to other sites or questions that could help me understand are fine.
0
Comment
Question by:trevorhigbee2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
crisco96 earned 500 total points
ID: 18862956
Filling a DataTable requires that you already have an instance of the DataTable declared and you pass the Table as an argument to the function for example:
     DataTable dt1 = new DataTable;
     SomeObject.Fill(dt1);
     // do something with the data table now as it has data

Returning a data table doesn't require you to have an instance of DataTable already declared, the function will return a new, filled instance of data table, for example:
     DataTable dt1; //we don't have to declare a new instance
     dt1 = SomeObject.SomeMethod();
0
 
LVL 2

Author Comment

by:trevorhigbee2000
ID: 18864498
So why would I want to do one over the other?
What is an example of SomeObject in the first example?
What is an example of SomeObject in the second example?

I'm new to 2.0.  I was thrown onto a 1.1 project about 5 months ago, and have just been learning whatever since then.  The only time I used fill in 1.1 was like this:

Dim ds As New DataSet
Dim da As New SqlDataAdapter("SELECT * FROM Table WHERE special = 0", conn)
da.Fill(ds, "someTableName")

So is 'SomeObject' in your example a data adapter?
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 54
wrapping text in datagridview header columns 1 30
EF5 How do I stop pre-compiled views? 8 54
How do I "share" on social sites? 2 39
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question