Last active
July 7, 2017 18:45
-
-
Save bahusoid/16c01f2afc9408b81b5592bef5f7a9ab to your computer and use it in GitHub Desktop.
ADO.NET DataTable case sensitive column search for "i" in Turkish locale (tr-TR)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("tr-TR"); | |
using (SqlConnection con = new SqlConnection(northwindDbConnectionString)) | |
using (SqlCommand com = new SqlCommand("select top 1 ProductID from Products",con)) | |
{ | |
con.Open(); | |
DataTable dt = new DataTable(); | |
SqlDataAdapter adapter = new SqlDataAdapter(com); | |
adapter.Fill(dt); | |
//Will work OK as casing for I is the same as in DB (but other chars in different casing) | |
var valueOk = dt.Rows[0]["PRODUCTId"]; | |
//Casing for I is different. In DB it's "I", in code it's "i". Will throw exception: Column 'ProductiD' does not belong to table Table1. | |
var valueException = dt.Rows[0]["ProductiD"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment