Solved

Difference between Fill and Return DataTable in VS 2005

Posted on 2007-04-05
2
700 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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