Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 dataset relation error

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-08-27 : 14:52:54
In my VS.net 2003 project, I got an error on the line of code that I try to
build a relationship between two tables.

dsProd.Relations.Add("SegtoCat", dsProd.Tables("Segments").Columns("ID"),_
dsProd.Tables("Catagories").Columns("SegmentID"));

'System.Data.DataSet.Tables' denotes a 'property' where a 'method' was
expected

Both tables have the right data populated, and PK ID in Segments table
points to SegmentID as FK in Catagories table.

Your help is truly appreciated!

Hommer
Aged Yak Warrior

808 Posts

Posted - 2004-08-27 : 15:26:11
I got it. Either of the following works. It was those ()s that have caused me the trouble. Changing them to []s, problem solved. The sample code was for vb, and I am using C#.

dsProd.Relations.Add("SegtoCat", dsProd.Tables["Segments"].Columns["ID"], dsProd.Tables["Catagories"].Columns["SegmentID"]);

or

DataRelation SegtoGat = dsProd.Relations.Add(dsProd.Tables["Segments"].Columns["ID"], dsProd.Tables["Catagories"].Columns["SegmentID"]);
Go to Top of Page
   

- Advertisement -