Solved

VB.NET bindingsource.find not working

Posted on 2010-11-16
2
1,613 Views
Last Modified: 2012-05-10
This is a second part to http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26616925.html#a34147039

I have a form that opens with a bindingsource on it and I want to set it to a particular record.  In the form, I have the following:
 
Public Sub New(ByVal idNum As Integer)
        InitializeComponent()
        Debug.WriteLine("ID passed = " & idNum)
        Dim row As Integer
        row = CustomerTBLBindingSource.Find("CustomerID", row)        
        Debug.WriteLine("Index=" & row)
        If row <> -1 Then
            CustomerTBLBindingSource.Position = row
        End If

Open in new window


I can't get the find to work for the life of me!  The table has 3 records with CustomerIDs of 1,2 and 3.  The field is set to the primary key with a value of int.  I even tried:

    row = CustomerTBLBindingSource.Find("LastName", "Bob")

Where one of the records has Bob for the LastName, but it always returns an index of -1.  I have found all kinds of examples identical to this and they seem to work for everyone else.  Any ideas what's wrong or how I can debug it?
0
Comment
Question by:roarteam
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34150433
"The Find method can only be used when the underlying list is an IBindingList with searching implemented."

http://msdn.microsoft.com/en-us/library/ms158165.aspx
0
 

Author Comment

by:roarteam
ID: 34154447
Thanks CodeCruiser.  What I did was use the filter property instead:
 
Me.CustomerTBLBindingSource.Filter = "CustomerID = " & idNum

Open in new window

Works like a charm!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question