How do I make string datacolumns case insensitive in a datarelation

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a dataset with multiple datatables linked via datarelations. These relations appear to be case sensitive on datacolumns that are a string datatype. I have setup the dataset to be casesensitive = false but it has no impact on the datacolumns.
Here is a simple test project I created to test this and display the results in two datagridview controls. If I change this code to create the datacolumns as SQLString types it works fine. I assume I am overlooking something simple but I am not sure what that would be...
Dim ds As New DataSet
Dim dt As New DataTable("Parent")
Dim dt2 As New DataTable("Child")
ds.CaseSensitive = False
Dim col As New DataColumn
col.ColumnName = "EmpNum"
col.DataType = GetType(System.String)
dt.Columns.Add(col)
col = New DataColumn("Name", GetType(System.String))
dt.Columns.Add(col)
col = New DataColumn("EmpNum", GetType(System.String))
dt2.Columns.Add(col)
col = New DataColumn("Age", GetType(Integer))
dt2.Columns.Add(col)

Dim row As DataRow
row = dt.NewRow()
row.Item("EmpNum") = "TEST"
row.Item("Name") = "Jim"
dt.Rows.Add(row)
row = dt.NewRow()
row.Item("EmpNum") = "temp"
row.Item("Name") = "John"
dt.Rows.Add(row)
row = dt2.NewRow()
row.Item("EmpNum") = "test"
row.Item("Age") = 44
dt2.Rows.Add(row)
row = dt2.NewRow()
row.Item("EmpNum") = "TEST"
row.Item("Age") = 48
dt2.Rows.Add(row)
row = dt2.NewRow()
row.Item("EmpNum") = "TEMP"
row.Item("Age") = 55
dt2.Rows.Add(row)
ds.Tables.Add(dt)
ds.Tables.Add(dt2)
Dim relation As New DataRelation("ParentChild", dt.Columns("EmpNum"), dt2.Columns("EmpNum"), True)
ds.Relations.Add(relation)

Dim bs As New BindingSource
Dim bs2 As New BindingSource
bs.DataSource = ds
bs.DataMember = "Parent"
bs2.DataSource = bs
bs2.DataMember = "ParentChild"

Me.DataGridView1.DataSource = bs
Me.DataGridView2.DataSource = bs2

View the full article
 
Back
Top