problem with datarelationship

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aussie Rules

    problem with datarelationship

    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("s elect * from projectcosts", dbConnection)
    Dim ds As New DataSet
    Dim da As New OleDbDataAdapte r(command)

    da.Fill(ds, "ProjectCos ts")

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



    da.Fill(ds, "Categories ")

    ds.Relations.Ad d("Root", ds.Tables("Cate gories").Column s("Category_ID" ),
    ds.Tables("Proj ectCosts").Colu mns("Category_I D"))




  • Steve Gerrard

    #2
    Re: problem with datarelationshi p

    Aussie Rules wrote:
    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.Ad d("Root",
    ds.Tables("Cate gories").Column s("Category_ID" ),
    ds.Tables("Proj ectCosts").Colu mns("Category_I D"))
    I suspect that the primary key on Categories is not getting set. If not, you
    could try adding it yourself:

    ds.Tables("Cate gories").Primar yKey = New Columns() {
    ds.Tables.Colum ns("Category_ID ") }


    Comment

    Working...