Solved

Difference between Fill and Return DataTable in VS 2005

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

756 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