[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Binding + Database Linking - 500 pts

Posted on 2006-04-07
4
Medium Priority
?
181 Views
Last Modified: 2010-04-23
I have asked a similar question to this before, however this time I will provide the full scenario.

I have a contact table which has all the usual fields plus PhoneNumber and PhoneDescription 1 -5

These fields are bound to a form, the reason for keeping them all within the same table was to provide easier binding. It allows the user to change each phone description and number very easily. I choose five as this will be the maximum it will ever be.


The problem I have is that I am still wondering whether the contacts phone numbers should go in another table, the problem is that while it is the correct way to link it, it causes significant coding to get it working.

Ideas anyone
0
Comment
Question by:rocky050371
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
Jayadev Nair earned 1000 total points
ID: 16400539
I hope you are working with datatables.

Say DataTable1 have your usual fields with a PKey
Make another table DataTable2 with PKey, ContactPhone and ContactDescription.
Create a DataSet (Dim ds as New System.Data.Dataset)
ds.Add(DataTable1)
ds.Add(DataTable2)
'\\ Relate Parent Table(usual fields) with Phone Table as shown below
ds.relations.Add("RelationName",ds.Tables(0).Columns("PKey"),ds.Tables(1).Columns("PKey"))

and for data binding, use ds.Tables(0).DefaultView.
Hope this will help you.
Cheers!!!
0
 

Author Comment

by:rocky050371
ID: 16400568
No I am not, the form is bound to the object.
0
 

Author Comment

by:rocky050371
ID: 16400597
It works like this


        Me.cboTitles.DataBindings.Add("Text", _currentcontact, "Title")
        Me.txtForename.DataBindings.Add("Text", _currentcontact, "FirstName")
        Me.txtSurname.DataBindings.Add("Text", _currentcontact, "LastName")
        Me.cboSalutation.DataBindings.Add("Text", _currentcontact, "Salutation")
        Me.cboDisplayAs.DataBindings.Add("Text", _currentcontact, "DisplayAs")
        Me.txtAddress1.DataBindings.Add("Text", _currentcontact, "Address1")
        Me.txtAddress2.DataBindings.Add("Text", _currentcontact, "Address2")
        Me.txtAddress3.DataBindings.Add("Text", _currentcontact, "Address3")
        Me.txtAddress4.DataBindings.Add("Text", _currentcontact, "Address4")
        Me.txtAddress5.DataBindings.Add("Text", _currentcontact, "Address5")
        Me.txtPostcode.DataBindings.Add("Text", _currentcontact, "Postcode")
        Me.btnPhone1.DataBindings.Add("Text", _currentcontact, "PhoneDescription1")
        Me.txtPhone1.DataBindings.Add("Text", _currentcontact, "PhoneNumber1")
        Me.btnPhone2.DataBindings.Add("Text", _currentcontact, "PhoneDescription2")
        Me.txtPhone2.DataBindings.Add("Text", _currentcontact, "PhoneNumber2")
        Me.btnPhone3.DataBindings.Add("Text", _currentcontact, "PhoneDescription3")
        Me.txtPhone3.DataBindings.Add("Text", _currentcontact, "PhoneNumber3")
        Me.btnPhone4.DataBindings.Add("Text", _currentcontact, "PhoneDescription4")
        Me.txtPhone4.DataBindings.Add("Text", _currentcontact, "PhoneNumber4")
        Me.btnPhone5.DataBindings.Add("Text", _currentcontact, "PhoneDescription5")
        Me.txtPhone5.DataBindings.Add("Text", _currentcontact, "PhoneNumber5")
        Me.txtEmail.DataBindings.Add("Text", _currentcontact, "Email")
        Me.chkPrimaryContact.DataBindings.Add("Checked", _currentcontact, "PrimaryContact")
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

873 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