none
Issues fetching data RRS feed

  • Question

  • I am developing for a multilanguage software with support for arabic, chinese, english, spanish, etc, recently we at the office are adding support for vietnamese. And I found a bug. When I set my windows locale to Vietnam and its format to Vientamese. I am not able to fetch a column, when I checked the query I had "Select Fieldname1, FieldName2 from Table" as query and the data set was trying to fecth the data from the dataSet using

    void TakeOverWorld(){
    
    // --- start variables, and execute query.
    
          foreach (DataRow row in data.Tables[0].Rows)
                    {
                        FieldName1 = Convert.ToInt32(row["FieldName1"]);
                        FieldName2 = Convert.ToInt32(row["FieldName2"]);
                        
    
                    //---rest of code
    
                    }
    }

    An exception was thrown saying  that "FieldName" could not be found.

    Column 'FieldName1' does not belong to table Table1.
    
    at System.Data.DataRow.GetDataColumn(String columnName)
       at System.Data.DataRow.get_Item(String columnName)

    Could you please confirm that this is a bug in the library? It happens that Vietnamese by default is case sensitive while the rest of languages (at least the ones I worked with before) are not.

    Edit: I fixed it by capitalizing correctly with the naming convention we are using, but I think that the intent is to have it non-case-sensitive by default. And before you ask, no, I do not have repeated column names in the query.
    Friday, April 6, 2018 2:47 PM

All replies

  • Hi GenaroArteagaSalinas,

    Based on your description, I create a simple and change location to Vietnam, which works well. please try the following code, which get ColumnName from data.Tables[0].Columns and check if it works for you.

    foreach (DataRow row in data.Tables[0].Rows) {
        foreach (DataColumn col in data.Tables[0].Columns) {
            object value = row[col.ColumnName];
        }
    }

    Best regards,

    Zhanglong


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 9, 2018 4:54 AM
    Moderator