![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello. I need to build a primary key (DataTable.primaryKey) programmatically, but it has more then one column. I didn't find any method for doing that. How can I do that ? |
#3
| |||
| |||
|
|
Am 08.07.2010 17:26, schrieb Mr. X.: Hello. I need to build a primary key (DataTable.primaryKey) programmatically, but it has more then one column. I didn't find any method for doing that. How can I do that ? The type of DataTable.primaryKey is an array. An array can contain more items. -- Armin |
#4
| |||
| |||
|
|
Yes, I know. but I did something like this : myTable.PrimaryKey = New DataColumn() {} myTable.PrimaryKey.SetValue(New DataColumn("aKey"), 0) ... and I get out of bounds on the second line. What is the correct syntax? |
#5
| |||
| |||
|
|
Am 08.07.2010 19:53, schrieb Mr. X.: Yes, I know. but I did something like this : myTable.PrimaryKey = New DataColumn() {} myTable.PrimaryKey.SetValue(New DataColumn("aKey"), 0) ... and I get out of bounds on the second line. What is the correct syntax? myTable.PrimaryKey = New DataColumn() {firstcolumn, secondcolumn} Otherwise you assign an empty erray and SetValue fails because there is no space in the array. -- Armin |
#6
| |||
| |||
|
|
I don't know how much columns will be on first time, and I want dynamically to change it (I don't know if there are two, or ten, so {firstColumn, secondColumn} may not be the best solution. |
#7
| |||
| |||
|
|
Am 08.07.2010 22:24, schrieb Mr. X.: I don't know how much columns will be on first time, and I want dynamically to change it (I don't know if there are two, or ten, so {firstColumn, secondColumn} may not be the best solution. You can always assign a new array to the PrimaryKey property. -- Armin |
#8
| |||
| |||
|
|
The situation : I am doing a loop, and each time I can add only one element to the primaryKey, so I must resize the array, without clearing it, but I don't know how to do that. |
#9
| |||
| |||
|
|
Am 08.07.2010 22:51, schrieb Mr. X.: The situation : I am doing a loop, and each time I can add only one element to the primaryKey, so I must resize the array, without clearing it, but I don't know how to do that. In the loop, collect the columns in a List(Of DataColumn). After the loop, set the PrimaryKey to YourList.ToArray. -- Armin |
#10
| |||
| |||
|
|
Am 08.07.2010 22:51, schrieb Mr. X.: The situation : I am doing a loop, and each time I can add only one element to the primaryKey, so I must resize the array, without clearing it, but I don't know how to do that. In the loop, collect the columns in a List(Of DataColumn). After the loop, set the PrimaryKey to YourList.ToArray. -- Armin |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |