Solved

VB.NET bindingsource.find not working

Posted on 2010-11-16
2
1,642 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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