Replacement for Recordset Bookmark?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wayne  Wengert

    Replacement for Recordset Bookmark?

    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

    varBookmarkCoun t = 0 'Count or entries with no Email address

    myRS2.MoveFirst ()

    Do Until myRS2.EOF

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

    arySendTo(varSe ntToCount) = Trim(myRS2!Emai l)

    varSentToCount = varSentToCount + 1

    Else ' No email addr

    arytmp(varBookm arkCount) = myRS2.Bookmark

    varBookmarkCoun t = varBookmarkCoun t + 1

    If varBookmarkCoun t > 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


  • Cor Ligthert

    #2
    Re: Replacement for Recordset Bookmark?

    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
    [color=blue]
    >
    > =============== =============== =============== =
    > varSentToCount = 0 'Count of recipients
    > varBookmarkCoun t = 0 'Count or entries with no Email address
    > myRS2.MoveFirst ()
    > Do Until myRS2.EOF
    > If InStr(myRS2!Ema il, "@") > 0 Then 'See if there is an Email address
    > arySendTo(varSe ntToCount) = Trim(myRS2!Emai l)
    > varSentToCount = varSentToCount + 1
    > Else ' No email addr
    > arytmp(varBookm arkCount) = myRS2.Bookmark
    > varBookmarkCoun t = varBookmarkCoun t + 1
    > If varBookmarkCoun t > 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[/color]


    Comment

    • Wayne  Wengert

      #3
      Re: Replacement for Recordset Bookmark?

      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

      "Cor Ligthert" <notfirstname@p lanet.nl> wrote in message
      news:uXrLRxdUEH A.4048@TK2MSFTN GP12.phx.gbl...[color=blue]
      > 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
      >[color=green]
      > >
      > > =============== =============== =============== =
      > > varSentToCount = 0 'Count of recipients
      > > varBookmarkCoun t = 0 'Count or entries with no Email address
      > > myRS2.MoveFirst ()
      > > Do Until myRS2.EOF
      > > If InStr(myRS2!Ema il, "@") > 0 Then 'See if there is an Email address
      > > arySendTo(varSe ntToCount) = Trim(myRS2!Emai l)
      > > varSentToCount = varSentToCount + 1
      > > Else ' No email addr
      > > arytmp(varBookm arkCount) = myRS2.Bookmark
      > > varBookmarkCoun t = varBookmarkCoun t + 1
      > > If varBookmarkCoun t > 248 Then
      > > MsgBox("Too many invalid email addresses to process!", vbOKOnly, "Too[/color][/color]
      many[color=blue][color=green]
      > > missing email addresses!")
      > > GoTo ExitEmailSub
      > > End If
      > > End If
      > > myRS2.MoveNext( )
      > > Loop[/color]
      >
      >[/color]


      Comment

      • Cor Ligthert

        #4
        Re: Replacement for Recordset Bookmark?

        Hi Wayne,

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

        I hope this helps?
        Cor


        Comment

        Working...