Solved

VB.NET bindingsource.find not working

Posted on 2010-11-16
2
1,674 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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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