Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi-column DataRelation Question

Status
Not open for further replies.

bazzerp

Programmer
Oct 6, 2008
4
GB
I am VERY new to VB.NET and VS2008 and have what is probably an easily solved problem:

I am trying to create a DataRelation between 2 tables both of which have the same 2 columns in their primary key.

I cannot see how I can create the DataRelation with anything other than two single columns.

Thanks in advance.
 
Take a look at this article, there is a VB .NET sample about halfway down the page.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks for the reply. However when I type the equivalent of

TransactionColumns = New DataColumn(){ds.Tables(0).Columns("TransID"), ds.Tables(0).Columns("CustomerID"), ds.Tables(0).Columns("SalePersonID")}

I get the error "Value of type '1-dimensional array System.Data.DataColumn' cannot be converted to 'System.Data.DataColumn'"

My actual code is:

Dim masterKey As DataColumn
masterKey = New DataColumn() {benchDS.Tables(1).Columns("bmk_ccy"), benchDS.Tables(1).Columns("bmk_id")}

Apologies for being like a complete novice - but that is what I am!

 

Do this:

Dim masterKey[red]()[/red] As DataColumn
masterKey = New DataColumn() {benchDS.Tables(1).Columns("bmk_ccy"), benchDS.Tables(1).Columns("bmk_id")}

The parentheses [red]()[/red] are needed to make masterKey an array instead of a single instance variable.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top