Finding If A Given Value Exists In DataCol

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have filled a dataset.tables("MYTBL") with n records, using the SQLDataAdapter.Fill() method. A Datacol("FNAME") is defined on the "MYTBL". For a given value , say fn_str, is it possible to find the row number within the Datacol("FNAME") where the value is first available / successively available. That is :

dim kt as integer = 0, fn_Str as string = "John
kt = ReadilyAvailableFunction(Datacol("FNAME"), fn_str
kt will get either of the two value sets : -1, or {0..n-1}. The -1 will indicate that "John" was not found. Successive instances of "John" could be obtained through some overloaded definitions of the same function

Ofcourse, the Readily ...() could be manually written. But whether already such a facility exists within the framework

Thanx in advance,

Sanjay
 
Sanjay:

Unless you create a datacolumn with Autoincrement set to true, or have such
a column implemented in yoru data table, then the "row number" isn't an
unchanging number. If you create such a column, you can do a find,
findrows, select etc and then reference the "RowNum" field that you created.
Otherwise, there is no real notion of rownum b/c the positioning doesn't
matter in ADO.NET

These articles deal with finding data, and all you'll need to do is pick an
appropriate scenario, add in the colum if it doesn't exist and reference its
rownmum that you create:

http://www.knowdotnet.com/articles/expressions.html (using datatable.Select)
http://www.knowdotnet.com/articles/adopartiii.html using datatable.Find

HTH,

Bill
Sanjay Agrawal said:
Hi,
I have filled a dataset.tables("MYTBL") with n records, using the
SQLDataAdapter.Fill() method. A Datacol("FNAME") is defined on the "MYTBL".
For a given value , say fn_str, is it possible to find the row number within
the Datacol("FNAME") where the value is first available / successively
available. That is :-
dim kt as integer = 0, fn_Str as string = "John"
kt = ReadilyAvailableFunction(Datacol("FNAME"), fn_str)
kt will get either of the two value sets : -1, or {0..n-1}. The -1 will
indicate that "John" was not found. Successive instances of "John" could be
obtained through some overloaded definitions of the same function.
Ofcourse, the Readily ...() could be manually written. But whether already
such a facility exists within the framework.
 
Back
Top