PRB: ADO Recordset Field Name with Letter "i" Is Case-sensitive with Turkish Settings

This article was previously published under Q279651
This article has been archived. It is offered "as is" and will no longer be updated.
SYMPTOMS
When you reference the fields of an ActiveX Data Objects (ADO) Recordset by name, for example, rs.Fields("ProductID").Value, in code that is running on a computer with Turkish regional settings, and those field names contain the letter "i" or "I", the evaluation of those field names may fail at run time. If the case of the letter "i" does not match the case of the field name in the database itself, you may receive the following error message:
Runtime error 3265, Item cannot be found in the collection corresponding to the requested name or ordinal.
Although this behavior is most commonly seen with Recordset field names, it also occurs with any other database object names (for example, table names) that are used as strings in ADO client code.

This problem does not occur in Microsoft Data Access Components (MDAC) version 2.1.
CAUSE
This problem occurs because the Turkish alphabet has two distinct letters that resemble the dotted and undotted letter "i". Beginning with MDAC 2.5, ADO treats the English lowercase letter "i" as a different Turkish letter than the English uppercase letter "I". This gives the impression of a case-sensitive comparison where a case-insensitive string comparison is expected.
RESOLUTION
To resolve this problem with Turkish regional settings, make sure that database object names that are used as strings in ADO code correspond to the case of the letter "i" that is used in the database itself.
MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a new Visual Basic Standard EXE project. Form1 is created by default.
  2. Set a reference to Microsoft ActiveX Data Objects 2.5.
  3. Place a command button on Form1.
  4. In the Command1_Click event procedure, paste the following code:

    Note You must change User ID=<UID> and password=<strong password> to the correct values before you run this code. Make sure that <UID> has the appropriate permissions to perform this operation on the database.
      Dim cn As ADODB.Connection  Dim rs As ADODB.Recordset  Dim fld As String  Set cn = New ADODB.Connection  cn.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;User ID=<UID>;Password=<strong password>;"  Set rs = New ADODB.Recordset  rs.Open "SELECT * FROM Products", cn, adOpenForwardOnly, adLockReadOnly, adCmdText  On Error GoTo errRs  fld = "ProductID"  Debug.Print rs.Fields(fld).Value  fld = "productid"  Debug.Print rs.Fields(fld).Value  On Error GoTo 0  rs.Close  Set rs = Nothing  cn.Close  Set cn = Nothing  Exit Sub  errRs:  Debug.Print "Field name comparison failure on: " & fld						
    Adjust the database connection string as necessary for an available SQL Server or a Microsoft Access version of the Northwind database.
  5. Configure the regional settings to U.S. English or similar, and then run the project. The project runs to completion without error, successfully accesses the requested ADO field name twice (as both "ProductID" and "productid"), and prints the value of that field twice to the Immediate window. End the project.
  6. In Control Panel, click Regional Settings or Regional Options, and then change the setting to Turkish.
  7. Run the Visual Basic project again. The project successfully finds the "ProductID" field in the database but fails to find "productid" and returns the above-mentioned error message because the case of the letter "i" in the code does not match the case that is used in the database.
  8. Make sure to change your Regional Settings back to your appropriate locale.
i 'i' error 3265
Properties

Article ID: 279651 - Last Review: 02/28/2014 04:22:56 - Revision: 3.2

Microsoft Data Access Components 2.5, Microsoft Data Access Components 2.5 Service Pack 1, Microsoft Data Access Components 2.6, Microsoft Data Access Components 2.7

  • kbnosurvey kbarchive kbdatabase kbprb KB279651
Feedback