Microsoft KB Archive/279651

= PRB: ADO Recordset Field Name with Letter &quot;i&quot; Is Case-sensitive with Turkish Settings =

Article ID: 279651

Article Last Modified on 11/5/2003

-

APPLIES TO


 * 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

-



This article was previously published under Q279651



SYMPTOMS
When you reference the fields of an ActiveX Data Objects (ADO) Recordset by name, for example, rs.Fields(&quot;ProductID&quot;).Value, in code that is running on a computer with Turkish regional settings, and those field names contain the letter &quot;i&quot; or &quot;I&quot;, the evaluation of those field names may fail at run time. If the case of the letter &quot;i&quot; 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 &quot;i&quot;. Beginning with MDAC 2.5, ADO treats the English lowercase letter &quot;i&quot; as a different Turkish letter than the English uppercase letter &quot;I&quot;. 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 &quot;i&quot; that is used in the database itself.



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

Note You must change User ID= and password= to the correct values before you run this code. Make sure that  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 &quot;Provider=SQLOLEDB;Data Source=(local);Initial Catalog=Northwind;User ID=;Password= ;&quot; Set rs = New ADODB.Recordset rs.Open &quot;SELECT * FROM Products&quot;, cn, adOpenForwardOnly, adLockReadOnly, adCmdText On Error GoTo errRs fld = &quot;ProductID&quot; Debug.Print rs.Fields(fld).Value fld = &quot;productid&quot; 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 &quot;Field name comparison failure on: &quot; & fld Adjust the database connection string as necessary for an available SQL Server or a Microsoft Access version of the Northwind database. </li> 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 &quot;ProductID&quot; and &quot;productid&quot;), and prints the value of that field twice to the Immediate window. End the project.</li> In Control Panel, click Regional Settings or Regional Options, and then change the setting to Turkish.</li> Run the Visual Basic project again. The project successfully finds the &quot;ProductID&quot; field in the database but fails to find &quot;productid&quot; and returns the above-mentioned error message because the case of the letter &quot;i&quot; in the code does not match the case that is used in the database.</li> Make sure to change your Regional Settings back to your appropriate locale.</li></ol>

<div class="references_section">