我有一个名为dataTable
的DataTable对象,其中包含一个名为type
的列。
我想添加一个新列typedisplay
,并根据列type
填充其值。
我已经尝试过:
' Create columns for computed values
dataTable.Columns.Add("typedisplay", GetType(String))
For Each dr As DataRow In dataTable.Rows
Select Case dr["type"]
Case 0
dr["typedisplay"] = "Retail"
Case 1
dr["typedisplay"] = "Self Employed"
Case 2
dr["typedisplay"] = "Company"
End Select
Next
但是我得到BC30037字符在Select Case dr["type"]
行中无效。
我正在使用Visual Studio 2017-如果相关的话。
如果有帮助的人。正确的语法是使用dr("type")
和dr("typedisplay")
,而不是dr["type"] / dr["typedisplay"]