Replacement for Recordset Bookmark?

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

In VB6/ADO I used to use the code below to put all the records that did not
have a valid email address into an array which I used later to print mailing
labels. I am not aware of a NET equivalent. What is the right way to
approach this in NET?

Wayne

==============================================
varSentToCount = 0 'Count of recipients

varBookmarkCount = 0 'Count or entries with no Email address

myRS2.MoveFirst()

Do Until myRS2.EOF

If InStr(myRS2!Email, "@") > 0 Then 'See if there is an Email address

arySendTo(varSentToCount) = Trim(myRS2!Email)

varSentToCount = varSentToCount + 1

Else ' No email addr

arytmp(varBookmarkCount) = myRS2.Bookmark

varBookmarkCount = varBookmarkCount + 1

If varBookmarkCount > 248 Then

MsgBox("Too many invalid email addresses to process!", vbOKOnly, "Too many
missing email addresses!")

GoTo ExitEmailSub

End If

End If

myRS2.MoveNext()

Loop
 
Hi Wayne,

Are you using a recordset in VB.net or something else, when you use the
recordset than it is the same because the recordset is ADO, not really
dotNet.

The only thing is that your code looks a little bit classic, by not
declaring the value types and using goto ExitMailSub in stead of Exit Sub.
For the rest I would not see what needs to change when you are keep using
the recordset. (Where I advice to use the dataset).

I hope this helps?

Cor
 
Thanks for the response. In VB.NET I use datasets so the bookmark is not
there.. Most of my declarations are at the head of the Sub - I didn't
include all the code in the post.

My code is less than optimal but the reason for the GoTo was that I have all
the code to close the recordset, set objects to nothing and such in that
area. Hopefully, my new VB.NET code will be better.

Wayne
 
Hi Wayne,

Looping through a dataset is even easier than through a recordset
\\\
for each dr as datarow in ds.tables(0).rows
if dr("myfield") = x then
'dosomething with the dr
next
///
or
\\\
for i as integer = 0 to ds.tables(0).rows.count-1
dim dr = ds.tables(0).row(i)
if dr("myfield") = x then
etc.
////

I hope this helps?
Cor
 
Back
Top