primarykey problem

hey there, this is my code making a dataset

PublicClass Form2

Dim verkoopAs DataSet =New DataSet("Verkoop")

Dim verkoperAs DataTable = verkoop.Tables.Add("Verkoper")

Dim IndexKolomAs DataColumn

PrivateSub Form2_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

'verkoper.Columns.Add("Id", datatype(gettype as string))

With verkoper

With .Columns

.Add("Id").DataType =GetType(Guid)

.Add("Naam").DataType =GetType(String)

.Add("Straat").DataType =GetType(String)

.Add("Nr").DataType =GetType(String)

.Add("Postcode").DataType =GetType(String)

.Add("Woonplaats").DataType =GetType(String)

.Add("Land").DataType =GetType(String)

EndWith

dGVVerkoper.DataSource = verkoper

.PrimaryKey =new datacolumn [] {verkoper.columns["Id"]}

EndWith

EndSub

EndClass

i have tried many possibles for primarykey but i get always an error:

value of type 'system.data.datacolumn' cannot be converted to '1-dimensional array of system.data.datacolumn'

[4237 byte] By [AxeldraX] at [2007-12-26]
# 1

Hi,

For visual basic, it would be written like:

.PrimaryKey = new DataColumn() { verkoper.Columns("id")}

Hope it helps.

tangfx at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2
I get the same error trying to create a datarelation with multiple primary keys. I've tried doing the above and using the datacolumn as the primary key.

MyDataSet.Relations.Add(New DataRelation("MyRelation", NewDataColumn, MyForeignKeyTable("MyForeignKey") )

I've also tried:

MyDataSet.Relations.add(New DataRelation("MyRelation", {PKTable.Columns("PK1"), PKTable.Columns("PK2")}, MyForeignKeyTable.Columns("MyForeignKey")))

Any help is appreciated.

Daranee at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified