Mar*_*elo 3 c# vb.net datatable visual-studio system.data
我试过了:
ObjDTOleDBNFeIntegra.Rows(I)("[Cnpj Cpf]").ToString() //with brackets  
ObjDTOleDBNFeIntegra.Rows(I)("'Cnpj Cpf'").ToString() //with apostrophe  
ObjDTOleDBNFeIntegra.Rows(I)("Cnpj Cpf").ToString() //without anything  
我正在使用VB.NET,但这里的撇号注释似乎没有被识别出来.
我得到每个案例的例外:( 
Column '[Cnpj Cpf]' does not belong to table Table.失败)
 Column 'Cnpj Cpf' does not belong to table Table.      (失败)
 Column ''Cnpj Cpf'' does not belong to table Table.(失败)
当列名有空格时,我应该怎么做才能从dataTable中的字段中获取值?
Mar*_*ell 10
你有没看过专栏认为它叫什么?例如,它可能有下划线.循环遍历列并查找(抱歉,C#中的示例):
foreach(DataColumn col in table.Columns) {
    Debug.WriteLine(col.ColumnName);
}
实际上,如果你在循环中使用它,使用该列会更快,所以我可能会使用类似的东西:
DataColumn col = table.Columns["whatever"];
foreach(DataRow row in table.Rows) {
    Console.WriteLine(row[col]);
}
| 归档时间: | 
 | 
| 查看次数: | 26703 次 | 
| 最近记录: |