problem with datarelationship


A

Aussie Rules

Hi,
I am trying to setup a Hierarchical view of my data. The first table
(categories) contains a category_id which is an autonumber (access2007)
making it unique. It also is the primary key on the table with no duplicates
set.

The second table contains costs per category, and there are always several
costs per category.

The code below is what I am using however I get an error on the
ds.relationship line stating that 'These columns don't currently have unique
values'

The result set for each data set would like llike

'categories'

category_id Name

1 sampleName1
2 sampleName2
3 sampleName3

Project costs

category_id description amount

1 expense1 394
1 expense2 492
1 expense3 983



Dim command As New OleDbCommand("select * from projectcosts", dbConnection)
Dim ds As New DataSet
Dim da As New OleDbDataAdapter(command)

da.Fill(ds, "ProjectCosts")

Dim command2 As New OleDbCommand("select * from categories", dbConnection)



da.Fill(ds, "Categories")

ds.Relations.Add("Root", ds.Tables("Categories").Columns("Category_ID"),
ds.Tables("ProjectCosts").Columns("Category_ID"))
 
Ad

Advertisements

S

Steve Gerrard

Aussie said:
Hi,
I am trying to setup a Hierarchical view of my data. The first table
(categories) contains a category_id which is an autonumber
(access2007) making it unique. It also is the primary key on the
table with no duplicates set.

The second table contains costs per category, and there are always
several costs per category.

The code below is what I am using however I get an error on the
ds.relationship line stating that 'These columns don't currently have
unique values'

ds.Relations.Add("Root",
ds.Tables("Categories").Columns("Category_ID"),
ds.Tables("ProjectCosts").Columns("Category_ID"))

I suspect that the primary key on Categories is not getting set. If not, you
could try adding it yourself:

ds.Tables("Categories").PrimaryKey = New Columns() {
ds.Tables.Columns("Category_ID") }
 

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

Top