473,796 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataBinding (one to one relationship)

Hello,

I have a small Access database with 5 tables. I have
created a form in C# that I would like to bind to 2 tables
(Contacts & Categories). The categories table is more or
less a lookup table. Can anyone give me a small example on
how to bind 2 controls (textbox and combobox) to 2
different fields with these related tables (one to one
relationship). I know I need to create a datarelation
object but I can't seem to find a decent C# example
anywhere.

Thank You,

Keith

Nov 15 '05 #1
1 2097
Keith,

1. Create a typed dataset with these two tables and a relation between them
2. Bind the text box to the "master" table by specifying the master table
name as the data member for the corresponding Binding class
3. Bind the combo box to the relationship by specifying
"<MasterTableNa me>.<RelationNa me>" as its data member.

I don't have an example but these should be the basic steps to start with.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Keith Kroculick" <kk********@hot mail.com> wrote in message
news:0f******** *************** *****@phx.gbl.. .
Hello,

I have a small Access database with 5 tables. I have
created a form in C# that I would like to bind to 2 tables
(Contacts & Categories). The categories table is more or
less a lookup table. Can anyone give me a small example on
how to bind 2 controls (textbox and combobox) to 2
different fields with these related tables (one to one
relationship). I know I need to create a datarelation
object but I can't seem to find a decent C# example
anywhere.

Thank You,

Keith


Nov 15 '05 #2

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

Similar topics

2
1915
by: Johann Blake | last post by:
I've been playing around trying to bind textbox controls and datagrids to typed datasets. Up until recently, I never used DataBindings. I always manually wrote the value into a textbox and stored its value after the textbox lost focus or whenever someone manually saved the record. I came to the conclusion after a long time and after many apps have been developed that there had to be a better way. What I thought would have been great is...
6
2170
by: Leon Shaw | last post by:
have two Dropdownlist and one which is containing States and one containing Cities. I know how to do all the little databinding task in visual studios interface as well as set the relationship (parent, child, etc.). In the code behind file in page_load event I fill the data adapter and databind the State dropdownlist. I also set the on_change event for the Cities dropdownlist after a state is selected. However, When I run this page in the...
2
3554
by: Leon Shaw | last post by:
have two Dropdownlist and one which is containing States and one containing Cities. I know how to do all the little databinding task in visual studios interface as well as set the relationship (parent, child, etc.). In the code behind file in page_load event I fill the data adapter and databind the State dropdownlist. I also set the on_change event for the Cities dropdownlist after a state is selected. However, When I run this page in the...
3
3165
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method, depending on which menu item a user selects. Each of these controls follows the same basic pattern: Get a dataset from the database and then display the results using basic databinding. Everything works fine except that I'll occaisionally get an...
2
2820
by: Neil Steventon | last post by:
Hi , I have started developing a database application , I say start as at this rate I see no finish. I have a windows form which is bound to mydataset table "Companys" and this works great binding the text boxes etc such as ; txtCompanyTelNo.DataBindings.Add("Text", myDataSet, "Companys.CompanyTelNo") I then want a datagrid to display a list of contacts for the company, which would be easy if it was a 1:m relationship, but a contact...
1
1573
by: Bruce D | last post by:
I'm new to VB.NET and I think I may have a stupid question. I'm just now understanding the dataview,datagrid relationship. I have created a dataview from a MySQL database. I'm doing everything programatically. So, I have this datagrid on my form which displays the data from my tables...my question...if I edit a field in the grid, how do I update the database? Here's a small example of what I'm doing. I'm lost...any help is...
3
7777
by: Alec MacLean | last post by:
Hi everyone, I have a ComboBox that when changed, calls a method to change the content of a ListBox. I'm also using the Listbox's SelectedIndexChanged event to change other control values on the form. (It's a Company -> People -> Personal Data relationship) When I bind my datasource to the ListBox, I find that the
3
1837
by: Grant | last post by:
I need some sample code showing how to manipulate data in my access database using C#. This is what Im trying to do: Dropdownlist with datagrid both bound to datasource. When the drop down list value changes - the datagrid values change accordingly. I managed to get this working by setting the currencymanager to the dropdownlist selectedIndex (which is probably the wrong way to do it, bu the datagrid seems to update its values correctly)...
5
4878
by: Uncle Sammy | last post by:
Hey all, I am trying to use a Listbox control with two data bindings. I cannot get the listbox to change the textboxes. Here's the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing;
0
9680
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
9528
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,...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10228
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2925
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.