VB Realtionships - Newbie

M

Merlin

Hi group, i`ve looked everywhere now and i think i know less than i did
before i started, im getting so frustrated with this now:(

This must be so Simple i just don`t know how to do it tho:(

I want to be able to have a ComboBox on a normal WinForm select it and pull
a list of all Sites from my Sites feild in my Sites Table, however my
SitesID Feild in the ArcUsers Table is a Lookup to the Sites Feild in my
Sites Table.

A Colleuge has just told me he thinks its something to do with binding(s)

My tables are as follows:

ARCUSERSID(PrimaryKey)
Name
BOMID
TILLID
SitesTABLE:
SITEID (This has a Relationship to and looks up all feilds in Sitename on my
Sites Table)

SITEID(PrimaryKey)
SITENAME
CONTACT

I created my Dataset and in the SQL Creation editior created the join etc
etc:

SELECT ArcirisUsers.Usersname, ArcirisUsers.POSID,
ArcirisUsers.POSAccess, ArcirisUsers.[Password], ArcirisUsers.LiveDate,
ArcirisUsers.BomID,
ArcirisUsers.BomAcc, Sites.[Site Name],
ArcirisUsers.ArcirisUsersID, Sites.SitesID
FROM ArcirisUsers INNER JOIN
Sites ON ArcirisUsers.SitesID = Sites.SitesID

How do I populate my ComboBox so that it displays the list of Sites from my
Sites Table on My Sitename in my Arciris Table

I tryed setting the Datasource to the SiteName in the Arciris Users Table
but it lists the SitesName in each row in my table (400+) and not my
Sitename in my Sites table

I think i need something like this:

odaArcirisDataAdapter.Fill(dsArcirisUsers)
cboArcirisSiteName.DataBindings.Add("Text", dsArcirisSiteName
"Sites.SiteName")

But im not Sure?

Could anybody Help
Many thanks
Merlin
 
C

Cor

Hi Merlin,

You are something further
odaArcirisDataAdapter.Fill(dsArcirisUsers)
cboArcirisSiteName.Datasource = dsArcirisUsers.table(0)
cboArcirisSiteName.displaymember = "A field you choose"
cboArcirisSiteName.valuemember = "Another field"

With that you can proces your dataset to get the other fields.

I hope this helps,

Cor
 
M

Merlin

When i run this I get a error saying:

"Table is not a member of dsArcirisUsers" on:

cboArcirisSiteName.Datasource = dsArcirisUsers.table(0)

Any Ideas?

Many Thanks
Merlin
 
K

Ken Tucker [MVP]

Hi,

cboArcirisSiteName.Datasource = dsArcirisUsers.Tables(0)

Ken
----------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VB Reationship - Newbie 2
Sql Statement Error 9
Going Crazy nearly 2 weeks 1
Binding and things on ComboBox 1
Sql Statement Errors 5
Going Crazy with this! 1

Top