Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Bindingsource.find not working as expected

$
0
0

I have bindingsource.find problem - hopefully someone has thoughts as to why it is not working. Here is the code:

    Private Sub WriteDateAddedData(ByVal NewRecordScottNumber As Object)

        StampCollectionTableAdapter1.Fill(SCDBDataDataSet1.StampCollection)
        StampCollectionBindingSource1.MoveFirst()
        StampCollectionBindingSource1.Position = StampCollectionBindingSource1.Find("ScottIndex", NewRecordScottNumber)

        MsgBox(StampCollectionBindingSource1.Position.ToString)

        CType(Me.StampCollectionBindingSource1.Current.Row, SCDBDataDataSet1.StampCollectionRow).DateAddedToDB = Date.Today

        StampCollectionBindingSource1.EndEdit()
        TableAdapterManager1.UpdateAll(SCDBDataDataSet1)
    End Sub

In the code above, the sub is called an passed a string to look for.  The find - in this case incorrectly sets the position to 0 and writes the data there.

If I manually put in the object to search for in the find as in:

StampCollectionBindingSource1.Position = StampCollectionBindingSource1.Find("ScottIndex", "Aruba3")

This works perfectly - it finds the proper row and writes the data.

I have tried to TRIM the variable (it's already trimmed when passed anyway) - did not work. 

I have tried to define the inbound variable as string - did not work.

I have tried to place a single quote mark around the data - did not work.

Yes - the field "ScottIndex" is defined as the primary key for the bindingsource.

Any thoughts???

Thanks,

Roger


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>