You are on page 1of 17

Article ID: 279651 - Last Review: November 5, 2003 - Revision: 3.

PRB: ADO Recordset Field Name with Letter "i" Is Case-sensitive with Turkish Settings
View products that this article applies to. This article was previously published under Q279651

On This Page
Expand all | Collapse all

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. Back to the top

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. Back to the top

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. Back to the top

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.
5. 6. 7. 8. 9. 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>;" 10. Set rs = New ADODB.Recordset 11. rs.Open "SELECT * FROM Products", cn, adOpenForwardOnly, adLockReadOnly, adCmdText 12. On Error GoTo errRs 13. fld = "ProductID" 14. Debug.Print rs.Fields(fld).Value 15. fld = "productid" 16. Debug.Print rs.Fields(fld).Value 17. On Error GoTo 0 18. rs.Close 19. Set rs = Nothing 20. cn.Close 21. Set cn = Nothing 22. Exit Sub 23. 24. errRs:

25.

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. 26. 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. 27. In Control Panel, click Regional Settings or Regional Options, and then change the setting to Turkish. 28. Run the Visual Basic project again. The project successfully finds the "ProductID" field in the database but fails to find "productid" and returns the abovementioned error message because the case of the letter "i" in the code does not match the case that is used in the database. 29. Make sure to change your Regional Settings back to your appropriate locale. Back to the top

APPLIES TO

Back to the top Keywords: kbdatabase kbprb KB279651

Run time error '3265' item not found in this collection well,, somebody can help me?? i try to solve my problem for 2 days i don't know where's the error always item not found in this collection i want ask to u

what's wrong in this below syntax DtBeli.RecordSource = "SELECT * FROM Pembelian WHERE ID_BELI= 'XXXXXXXX' AND ID_BARANG = ' " & TxtIDBarang.Text & " ' AND ID_SUPPLIER = ' " & TxtIDSupplier.Text & " ' " what's wrong with it? i really don't know how to select from 3 tables,, bcz i'm a beginner in programming plz help me #2 July 8th, 2011, 11:39 AM DataMiser Elite Member Re: Run time error '3265' item not found in this collection Your syntax looks fine. If that line is the one throwing the error then it would indicate that either the table Pembelian does not exist or is not spelled properly or one of the three fields named is not correct. You mention selecting from 3 tables, if those occuring after the where are in different tables or are table names then the statement is way off. To select from multiple tables you must use a Join statement. __________________ Always use [code][/code] tags when posting code. #3 July 8th, 2011, 04:30 PM junita92 Junior Member Re: Run time error '3265' item not found in this collection i dont know how to use join on 3 tables can u help me??? how to use join in my syntax? #4 July 8th, 2011, 05:19 PM Join Date: Jul 2011 Posts: 3 Join Date: Jul 2008 Location: WV Posts: 3,914

dglienna ex MVP - Visual Basic Power Poster Re: Run time error '3265' item not found in this collection Look up SQL BOOKS ONLINE for syntax. This *might* help: Code:

Join Date: Jan 2006 Location: Chicago, IL Posts: 13,982

Private Sub Command1_Click() Dim cnLvConnection As ADODB.Connection Set cnLvConnection = New ADODB.Connection Dim rsLvRecordset As ADODB.Recordset Set rsLvRecordset = New ADODB.Recordset With cnLvConnection .Provider = "MSDataShape.1" .ConnectionString = "Data Source=" & App.Path & "\db1.mdb;" _ & "Data Provider=Microsoft.Jet.OLEDB.4.0;" .Open With rsLvRecordset .CursorLocation = adUseClient .CursorType = adOpenStatic .LockType = adLockReadOnly End With Set rsLvRecordset = .Execute("SHAPE {SELECT c.CustomerName As Customer, c.CustomerID FROM Customers c ORDER BY c.CustomerName} As Customers" _ & " APPEND ((SHAPE {SELECT oh.OrderNumber As [Order No], oh.CustomerID, oh.OrderHeaderID FROM OrderHeaders oh ORDER BY oh.OrderNumber} As OrderHeaders" _ & " APPEND ({SELECT od.OrderLine As [Line], od.OrderLineDescription As [Description], od.OrderLineQuantity As Quantity, od.OrderHeaderID FROM OrderDetails od ORDER BY od.OrderLine} As OrderDetails" _ & " RELATE OrderHeaderID TO OrderHeaderID))" _ & " RELATE CustomerID TO CustomerID)") End With ' Setup Grid Set Me.MSHFlexGrid1.Recordset = rsLvRecordset Me.MSHFlexGrid1.ColWidth(1, 0) = 0 ' c.CustomerID Me.MSHFlexGrid1.ColWidth(1, 1) = 0 ' oh.CustomerID Me.MSHFlexGrid1.ColWidth(2, 1) = 0 ' oh.OrderHeaderID Me.MSHFlexGrid1.ColWidth(3, 2) = 0 ' od.OrderHeaderID ' Tidy up If Not rsLvRecordset Is Nothing Then If rsLvRecordset.State <> adStateClosed Then rsLvRecordset.Close End If Set rsLvRecordset = Nothing End If If Not cnLvConnection Is Nothing Then If cnLvConnection.State <> adStateClosed Then cnLvConnection.Close

End If Set cnLvConnection = Nothing End If End Sub Private Sub Form_Load() Me.MSHFlexGrid1.FixedCols = 0 End Sub

__________________ David
CodeGuru Article: Bound Controls are Evil-VB6 2012 Samples: MS CODE Samples
CodeGuru Reviewer 2006 Dell CSP 2006, 2007 & 2008 MVP Visual Basic If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

#5 July 9th, 2011, 08:06 AM DataMiser Elite Member Re: Run time error '3265' item not found in this collection Quote: Originally Posted by junita92 i dont know how to use join on 3 tables can u help me??? how to use join in my syntax? It is not possible to show you the proper syntax to join 3 for your statement as you did not provide the required info. Your statement looks like it is selecting all fields from one table based on the values of 3 fields in that same table. If this is the intended result then your statement is ok. If the intention is to pull data from more than one table or based on values in more than one table then we would have to know the names of the tables and the names of the key fields which will be joined. For example in an order system you may have a table called Customers and another called Orders both tables may have a field named CustomerID which will allow you to get the customer info for a given order based on the ID in the order table. Code:
"Select * from customers inner join Orders.CustomerID on Customers.CustomerID

Join Date: Jul 2008 Location: WV Posts: 3,914

where Orders.OrderNumber=" & OrderNumber

The query above will return rows containing all the data for the given customer from the customers table as well as all the data from the orders table where ordernumber is equal to the one given but only it the customer number matches an entry in the customers table __________________ Always use [code][/code] tags when posting code. Last edited by DataMiser; July 9th, 2011 at 08:08 AM.

Runtime error 3265 - im using Access 2003 and VB6


DGNinja12

I get this error when i run, i cant figure out what is wrong
P: 1Can some one please help me?

Run-time error '3265': Item cannot be found in the collection corresponding to the requested name or ordinal.

Below is my code

Private Sub Form_Load()

medcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=M:\Herbal_Medicine_Database.mdb;Persist Security Info=False" medcon.Open medrs.Open "Select * from MedDetails ", medcon, adOpenDynamic, adLockOptimistic

DISP LockNow

End Sub

Public Sub DISP() 'coding to display record in textbox If Not (medrs.EOF = True Or medrs.BOF = True) Then txtRedgNum.Text = medrs.Fields.Item("RedgNum") txtComplnts.Text = medrs.Fields.Item("Complaints") ' on debug this is highlighted txtIllns.Text = medrs.Fields.Item("Illness") txtPstIllns.Text = medrs.Fields.Item("PastIllness") txtDrgPresc.Text = medrs.Fields.Item("DrugPrescribed") End If

End Sub Post Reply


Mar 3 '08 #1

3 Replies

Ads by Google PowerBasic vs VisualBasic www.powerbasic.com Faster. No Run-Times. No Bloat! CGI, Macros, ASM, Reg Expressions

VBWheaties
re: Runtime error 3265 - im using Access 2003 and VB6 100+ P:Item not found in this collection means the column does not exist. 144 Check your spelling. Lower case L's are sometimes confused with upper case i's.

If you still cant find it, run a loop of the items in the collection to see what they are named. Something like this: Expand|Select|Wrap|Line Numbers 1. 2. Dim I as Integer 3. 4. For I = 0 To MyRecordset.Items.Count - 1 5. 6. 7. 8. Next I 9. 10. Another idea is to explicitly set the field name in the select statement: SELECT Field1, Field2 FROM DataTable. instead of SELECT * because you'll only use those fields you need instead of returning a huge collection of columns you dont need.
Mar 3 '08 #2

Debug.Print "Field name is " & MyRecordset.Items(I).ColumnName

reply QVeen72
re: Runtime error 3265 - im using Access 2003 and VB6 Expert 100+ Hi, P: 1,434

Check field "Complaints" is present in Table MedDetails (In the connected database) Check the Spelling also..

Regards Veena
Mar 4 '08 #3

reply debasisdas
re: Runtime error 3265 - im using Access 2003 and VB6

Expert Mod 5K+Just check the spelling of the field in the database table. P: 6,607

Else use index in recordset in place on name of the fields.


Mar 4 '08 #4

Registered User

Join Date: Dec 2002 Posts: 10

runtime error 3265: item cannot be found in this collection Hello! I connected to sqlserver 7 db from vb6.I got one record displayed from my db table as rs.fields(0).If i give rs.fields(1) , it gives me the error, item cannot be found in this collection.When i dispalyed the record count as msgbox rs.recordcount it shows -1.what may be the error, pls help.

Lydia

#2 (permalink) 12-09-02, 22:18 rnealejr Registered User Join Date: Feb 2002 Posts: 2,232

Please provide your sql statement within vb - and which cursorlocation are you setting (client or server). It sounds like your sql statement is only returning 1 column. When you use rs.fields(1) accesses the 2nd column returned by your sql query not the next record in the recordset.

#3 (permalink) 12-10-02, 08:53 lydia Registered User ByVal ref argument type mismatch Hello! Thank you very much, i fixed the error as soon as i written to you.That is the same thing that you replied.It's coz i am quite new to VB and am learning. Two more issues - i need ur help 1. But still i am getting the record count as -1 . why is it? but i am getting all my records in the record set. Join Date: Dec 2002 Posts: 10

2. I created a function to fill up the list box as

Function FillList(Listitem as Listbox, FieldName as Field, TableName as Table)

----Code----Goes here End Function

when i tried to call the function as FillList(List1, m_email,members) it is returning error as : ByVal ref argument type mismatch how should i refer the values with the arguments in the function? Pls help Lydia

#4 (permalink) 12-10-02, 09:10 rnealejr Registered User Which cursorlocation are you using ? Join Date: Feb 2002 Posts: 2,232

#5 (permalink) 12-10-02, 10:31 lydia Registered User Quote:


Originally posted by rnealejr Which cursorlocation are you using ?

Join Date: Dec 2002 Posts: 10

What do you mean by cursor location? i gave the code like this: --some code here--opened the record set as AdopenforwardOnly

#6 (permalink) 12-10-02, 21:36 rnealejr Registered User Join Date: Feb 2002 Posts: 2,232

Both the connection and recordset objects contain a property called cursorlocation. If you are not setting it, go into debug and view the properties of the object and examine the cursorlocation property.

#7 (permalink) 12-11-02, 16:40 lydia Registered User Join Date: Dec 2002 Posts: 10

Thank you very much, After setting the cursor location, i got the correct record count.

#8 (permalink) 12-11-02, 19:15 rnealejr Registered User Happy to help. Join Date: Feb 2002 Posts: 2,232

#9 (permalink) 12-12-02, 17:54 lydia Registered User I have a function to fill up list box with a DB Field values as Public Function FillList(ListItem As ListBox, FieldName As Field,TableName as Table) Dim i As Integer i=0 DbConnect strSQL = "select FieldName from TableName" 'without using the connection object ObjRs.Open strSQL, strConn ' Add Items in the list box ObjRs.MoveFirst Do While Not ObjRs.EOF Join Date: Dec 2002 Posts: 10

ListItem.AddItem ObjRs(0), i ObjRs.MoveNext i=i+1 Loop 'Be sure you close and destroy your objects. ObjRs.Close ObjConn.Close Set ObjConn = Nothing Set ObjRs = Nothing End Function

' Then i called the function as call FillList(List1,"M_email","Members") It gives me error as : Type Mismatch What is the mistake in the code?

#10 (permalink) 12-12-02, 23:46 rnealejr Registered User Join Date: Feb 2002 Posts: 2,232

Please post the code before the FillList. How are the Field and Table referenced ( like through adodb ...) ?

#11 (permalink) 12-13-02, 07:07 lydia Registered User Type Mismatch Yes, I connected to the DB as ADODB.Connection Join Date: Dec 2002 Posts: 10

#12 (permalink) 12-13-02, 11:17 rnealejr Join Date: Feb 2002

Registered User

Posts: 2,232

How are you able to reference "Table" ? Also, you should be explicit in your declarations (Adodb.Field). The problem is that you are trying to pass a string to a function expecting an object. Both the field/table should be strings - so you would build your sql statement like: strSQL = "select " & FieldName & " from " & TableName

Run-time error '3265' Item not found in this collection.


Asked by: OnlineGuitarist Help, I'm getting an annoying error. I'm sure it's just my out of wack sytax usage, but please may someone help me. ******************************** Option Explicit Dim dbName As String Dim dbPath As String Dim dbNamePath As String ________________________________ Private Sub Form_Load() dbName = "\UserDat.zac" dbPath = "" & App.Path & "" dbNamePath = "" & dbPath & dbName & "" End Sub ________________________________ Private Sub Form_Activate() If FileExists(dbNamePath) = True Then Dim dbUser As Database Dim rsUserNames As Recordset Dim i As Integer Set dbUser = DBEngine.Workspaces(0).OpenDatabase(dbNamePath, dbOpenDynaset) Set rsUserNames = dbUser.OpenRecordset("tblUserNames", dbOpenTable) With rsUserNames If .EOF And .BOF Then Beep MsgBox "There are no listed users in the database." & vbCrLf & _

"You must first create a new user.", _ vbExclamation + vbOKOnly, _ "No Users Currently Exist" Unload Me Set dbUser = Nothing Set rsUserNames = Nothing ElseIf FileExists(dbNamePath) = False Then If MsgBox("Your database file seems to be missing." & vbCrLf & _ "What did you do with it? No worries." & vbCrLf & vbCrLf & _ "Do you want to create a new database?", _ vbExclamation + vbYesNo, _ "There is No Database!") = vbYes Then Me.Visible = False DatabaseMaintCreate Unload Me Else: Unload Me End If Else Set dbUser = DBEngine.Workspaces(0).OpenDatabase(dbNamePath, dbOpenDynaset) Set rsUserNames = dbUser.OpenRecordset("tblUserNames", dbOpenTable) .MoveFirst For i = 1 To .RecordCount cboUserNames.AddItem rsUserNames.Fields("tblUserNames") '******************************* 'The above line of code is where I receive my error. 'I get a Run-time error '3265' Item not found in this 'collection. This works ok when I add an item, such 'as: '*********** 'rs.additem 'rs.fields("fieldname") 'rs.update '*********** 'All other code works in this routine '******************************* rsUserNames.MoveNext Next Set dbUser = Nothing Set rsUserNames = Nothing End If End With End If End Sub This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

You might also like