Question creating new DataView using RowFilter which has a special character

gdh101

New member
Joined
May 30, 2013
Messages
2
Programming Experience
10+
Hello. I have a DataSet which is created/populated using ReadXML. Then I'm using the DataView with a RowFilter to select then loop through DataRowViews to query and extract data. Here's an example of a table, with the columns listed.

TABLE 'element'
Total # of rows: 42
---------------------------------------------------------------
- element_Id (System.Int32)
- name (System.String)
- uom (System.String)
- value (System.String)
- code-src (System.String)
- code-type (System.String)
- identification-elements_Id (System.Int32)
- elements_Id (System.Int32)

Whenever I use DataView using the RowFilter on a column with a hyphen, like code-type, VB doesn't like it and creates an error:
"A first chance exception of type 'System.Data.EvaluateException' occurred in System.Data.dll"

Here's an example:
Dim dv As DataView = New DataView(ds.Tables("element"), "code-type = 'present_weather'", "", DataViewRowState.CurrentRows)

I tried enclosing code-type in single or double quotes, but that doesn't work.

Any ideas?

Thanks,
Garth
 
Last edited:
Sorry. Found the answer. Need to enclose it in []

Dim dv As DataView = New DataView(ds.Tables("element"), "[code-type] = 'present_weather'", "", DataViewRowState.CurrentRows)
 
Back
Top