Hello,
I don’t think we can verify a DataColumn only through its caption. The column in a data row can be found by its index or column name. It seems that we can only cycle through the column list of the DataTable if we want to use the column caption to identity the column.
However, I think we can set the Column name and Caption to be the same string value, and it is valid. I don’t quite catch the point that the meaning of “the spaces cannot work in a query string”, because such sample codes can give us the correct result:
==========================================================================
DataTable dt = new DataTable();
dt.Columns.Add("New Column", typeof(int));
dt.Rows.Add(1);
MessageBox.Show(dt.Rows[0]["New Column"].ToString());
==========================================================================
Best Regards,
Lingzhi Sun
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.