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
Solved

Difference between Fill and Return DataTable in VS 2005

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expression Evaluater 3 37
How to read text with RegEx... 2 25
Finding the IIS version 5 21
C# class library debugging - Breakpoint will not hit. 8 16
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

792 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