473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Related Tables

Hello all:

I have a few questions regarding ADO.NET data access:

1. I have a DataSet that gets populated w/several tables,
but I would like to display a certain column in one of
those tables by pulling the related records from another
table. To put this clearer I have two tables in a
database, one w/shipping info and one w/drivers. They are
related by a driver id in each one. But how do I display
the shipping info w/a driver name that it pulls from the
drivers table rather than displaying the driver id?

2. What is the best way to create a connection that is
shared across multiple forms? Right now I have my main
form create a connection that I then feed to the other form
by means of a public variable. Is this how it should be done?

Thanks a bunch,

John
Nov 15 '05 #1
1 1480
1. Create a DataRelation locally...http://www.c-
sharpcorner.com/database/DataRelationVK.asp (there's
another good example on MSDN). In your control, you can
set the DisplayMember and ValueMember....so your
displaymember would be the name, the valuemember would be
the id this article covers it in depth...
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/dv_vstechart/html/vbtchNavigatingMultipleRelatedTablesIn
ADONETDataset.asp
As far as 2 goes, you can use a Config file to store the
connectionstring for instance, and instantiate a
connection each time you need one. Or, if you have to use
the same connection, create a Sealed Single Instance class
and have a static property of type connection (as long as
the property is static, you don't necessarily have to use
Sealed Single Instance, that's a matter of taste on my
part).

When Form1 loads, call a function to instantiate the
connection. you can reference it anywhere in the app
afterward by ObjectName.Instance.ConnectionPropertyName.

Let me knwo if you have any questions.

Good Luck,

Bill

W.G. Ryan
do********@comcast.nospam.net
www.knowdotnet.com
-----Original Message-----
Hello all:

I have a few questions regarding ADO.NET data access:

1. I have a DataSet that gets populated w/several tables,
but I would like to display a certain column in one of
those tables by pulling the related records from another
table. To put this clearer I have two tables in a
database, one w/shipping info and one w/drivers. They are
related by a driver id in each one. But how do I display
the shipping info w/a driver name that it pulls from the
drivers table rather than displaying the driver id?

2. What is the best way to create a connection that is
shared across multiple forms? Right now I have my main
form create a connection that I then feed to the other formby means of a public variable. Is this how it should be done?
Thanks a bunch,

John
.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
0
by: elvin | last post by:
Okay - apologize in advance for the length, but I want to make sure all you knowledgeable and helpful people have all the details you need to hopefully point my newbie rear in the right direction....
1
by: Christa Waggett | last post by:
Hi, I'm not a programmer but would appreciate some help with the following. I've been looking at various sites but cannot find the information I require. I have a table of strata plans and if we...
2
by: Bob | last post by:
I got three related datagrid views one parent and two children of the same. The two child tables contain many thousands of records and some of the contents are bitmap files in a sql server...
4
by: HLCruz via AccessMonster.com | last post by:
I am working with a database that has client information separated in to 4 related tables - tFolder, tAddress, tEmail, tPhone number. In addition there are related tables tGifts and tCalls. The...
0
by: kolalakitty | last post by:
Hopefully someone here can help me/point me in the right direction. I've found tons of references towards making relations, creating rows, saving said rows, using datagrids, databinding objects,...
0
by: gilbes | last post by:
I have been searching for a solution to this for a while now and everything I have found has lead me down the wrong path. Any assistance you guys could give would be much appreciated. I would...
5
by: upwardgazing | last post by:
I'm using Access 2003 (Access 2000 file format) and I have two tables related one-to-many called tblTempEncounter and tblTempEncounterDetails. I need to move a record from the first table with it's...
3
by: BASSPU03 | last post by:
(I'm using Access 2003 on a Windows XP O/S.) I have four tables that are related in the following order: tblFiscalYear > tblBulkObligations > tblProjects > tblResources These are their...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.