Solved

Difference between Fill and Return DataTable in VS 2005

Posted on 2007-04-05
2
671 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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now