can I predict index - 1 in a dataview?

  • Thread starter Thread starter Bernie Yaeger
  • Start date Start date
B

Bernie Yaeger

Let's say I create a dataset/datatable thusly:
Dim daprod As New SqlDataAdapter("select * from anreport order by bipad,
issuecode", oconn)

Dim dsprod As New DataSet("prod")

daprod.Fill(dsprod, "prod")

Then I set up a dataview using this table, in the same order:

Dim arrayseekp(1) As Object

Dim ifindp As Integer

Dim vuep As New DataView(dsprod.Tables(0))

vuep.Sort = "bipad, issuecode"

Dim xbipad, xissuecode As String

Dim irow as datarow

For Each irow In dsprod.Tables(0).Rows

arrayseekp(0) = irow("bipad")

arrayseekp(1) = irow("issuecode")

ifindp = vuep.Find(arrayseekp)

If ifindp <> -1 Then ' found it

xbipad = vuep(ifindp - 1)("bipad")

xissuecode = vuep(ifindp - 1)("issuecode")

End If

Next

Here's the question: will index ifindp - 1 be in fact the row above the
found row, such that if I find '12345' '200209', ifindp - 1 will be '12345'
'200208' (if there is one, or else '12344' etc)?

Thanks for any help.

Bernie Yaeger
 
Hi Bernie,

I did not use this one, but when I read it well in the documentation you are
rigtht.
When you check of course if it is not 0 before that.

You select a total table and sort that and uses an index to that sorted
index.

Bernie, can you do us a favor, when you post questions like this, paste it
first in the notebook, copy it back and paste it than in the message, than
it is much easier to find your problem.


Cor
 
Back
Top