Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data Binding

Posted on 2011-03-10
4
Medium Priority
?
217 Views
Last Modified: 2012-05-11
I am still learning C# and would like to know what the most efficient means is to bind data from a database into this simple application I have written. I'm still very confused by DataGrids, Data tables, Data Sets, Adapters, etc. I think there's something basic I am not getting.

The application is as follows:

The user enters some parameters X, Y, Z about themselves, and then the application goes to the datbase and finds X, Y, Z (all keys in the table) and returns A, B.  There is only ONE resulting row containing A and B, never more than one row. I need to display A and B on the page in a Label field, so how do I get this result and display it?

What should I use? Seems like overkill to use a Data grid or data table for just one resulting record.

Once I get the result set back, can I bind it to a label field? or does it have to be bound to a repeater (also overkill for this application).

I got as far as the DataAdapter, but I'm not sure what to do from there. Help!
0
Comment
Question by:vcbertini
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 35100063
You basically have a few groups of object that go together. A DataSet is a container object that holds one or more DataTables. A DataAdapter acts as an intermediary between between the DataSet and your database. DataReaders are fast, light-weight data objects that give you forward-only access to your data (this would be the most suitable in your scenario).

The DataGrid, Repeater, etc, are UI elements that display data stored in DataTables/DataSet or pulled back with a DataReader.

Labels are dumb, in the sense that the do not directly support databinding in their own right. They can pull data from a data source, but only when they are inside a data-aware control such as a grid or repeater, etc.  
0
 

Author Comment

by:vcbertini
ID: 35100083
So I would probably have to use a repeater even though there's nothing that will repeat?

...and I would bind the repeater to the data reader?
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35100101
Not necessarily. A DetailsView might suit your purpose because it is designed for displaying a single record at a time:

    http://msdn.microsoft.com/en-us/library/s3w1w7t4.aspx
0
 

Author Closing Comment

by:vcbertini
ID: 35100122
Hmm... Food for thought. Thank you very much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

824 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