473,830 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1508
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/vbtchNavigating MultipleRelated TablesIn
ADONETDataset.a sp
As far as 2 goes, you can use a Config file to store the
connectionstrin g 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.Inst ance.Connection PropertyName.

Let me knwo if you have any questions.

Good Luck,

Bill

W.G. Ryan
do********@comc ast.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
11110
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 have a primary form named TestResults, which is connected to data in a table named TestResults. There are basically two other tables that are related to the TestResults table (and the primary form) named Names-Normalized and SiteAddresses. The...
0
3214
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. I've got a fairly complex (a lot more complex than originally intended) database with three main tables. The database is designed to track information about certain files. The tables are set up with one to one relationships, primarily because...
1
1688
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 no longer manage the plan the date this occurs gets entered into a field. What I would like to happen is for all the fields in that record to change their forecolor to red as soon as the DateLost field is no longer null. I also have several...
2
1645
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 database. The default behaviour of loading all the contents of the parent data table and also all the related data is not acceptable, its takes too long to complete. What I need to do IMHO, is to load the parent table and after its loaded, and it gets...
4
3314
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 database has roughly 22,000 records but should only have around 6,000. The remaining records are duplicates, but in many cases the correct data for one person is spread out between the duplicate records and related tables. I need to be able to...
0
1734
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, and etc in regards to Windows Forms, C#, and Visual Studio .Net 2003. I seem to have run into a bit of a problem however. I'm not using datagrids to show related data, my users wouldn't have any idea how to use them, and they want to see all of...
0
1133
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 like to bind a control to an object data source control and get data from related tables. For example: Categories (table) -CategoryID
5
4151
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 related records from the second table into another pair of tables called tblEncounters and tblEncounterDetails. I've come up with a solution that seems really convulted to me, and it's snagging with multiple users. Will a single append query move data...
3
1910
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 fields: tblFiscalYear ==========
0
9780
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10520
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6940
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5615
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5775
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3956
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.