Groups | Blog | Home
all groups > vb.net data > april 2004 >

vb.net data : DataTable Find method...


Perry Ogletree
4/23/2004 5:12:24 PM
I'm trying to use the datatable find method to retrieve information from an
Access database. I retrieve the Access data into a dataset using:
daStationData.Fill(dsStationData,"dtblStationData")
The data is then displayed in a sorted datagrid via:
dgDisplay.SetDataBinding(dsStationData, "dtblStationData")
In another part of the application, I want to allow the user to enter a
station id and retrieve that station's data by using:
Dim foundRow As DataRow
foundRow = dtblStationData.Rows.Find(sCall) 'where sCall is a string
This fails (returns Nothing) when the database has data in it from an "old"
session, i.e. the app was run and data was entered in the empty
database,saved and the app exited. If I try the Find with a fresh database
with new entries, the Find works. I have verified that the datatable's
primary key is correct and can not figure out why it won't work all the
time!
Any ideas???

Thanks,
Perry

Perry Ogletree
4/24/2004 3:04:08 AM
Given enough time and enough monkeys....
I found that I have to re-"Fill" the dataset/datatable to get the find to
work. It seems that even if you declare the datatable at the module level,
it looses it's contents after being bound to the datagrid?!

[quoted text, click to view]

William Ryan eMVP
4/27/2004 9:53:58 PM
Why's that? That shouldn't be true, can you tell me more about the problem?
[quoted text, click to view]

AddThis Social Bookmark Button