I have a set of data that I am pulling from a database and putting into a datatable. When I assign the datatable to the DataSource of my grid, I get the error: "Key already exists Parameter name: Key"
I have found that two columns in the .Net DataTable have the same name, but different cases. Here is a short example to reproduce this:
1. Add a grid to the form and just click "Finshed" when the wizard comes up.
2. Add the following code:
Dim dt As New DataTable("Test")
Dim col1 As DataColumn = New DataColumn("Col 1", GetType(Double)) col1.Caption = "Col 1" dt.Columns.Add(col1)
Dim col2 As DataColumn = New DataColumn("COL 1", GetType(Double)) col2.Caption = "COL 1" dt.Columns.Add(col2)
UltraGrid1.DataSource = dt ' <--- Exception will occur here
The names of the DataColumns only differ in case. Aside from changing the names (since in the real world I will not have control of this and the names differing in case only is a potential in the data I have to use), is there a setting I am missing to keep this from happening.
I had the same problem, but in my case this error only happened when refreshing the data on the datasource, I set the datasource to nothing and set the new datasource from query, and this error appears "Key already exists Parameter name: Key".
I solve it doing some debugging on the stacktrace and find out that my initializelayout method was trying to add again the appearences already added to the wingrid
Hope if someone googles this error find this helpfull
I solved this problem. The keys were conflicting with the control on the form and some control's base class. I changed the keys and it solved the problem.
Thanks.
Hi,
can you please check the following screen shot:
http://picturepush.com/public/5094946
Can you please tell me what might have gone wrong? I have no idea how to fix this. Thanks!!
..ab
No, there's no way to turn it off.
is there anyway of turning this case sensitivety off?
This is really messing with me becuase of a mix between mssql and oracle..