Link to home
Start Free TrialLog in
Avatar of rowmark
rowmark

asked on

VB Code into VB.net confusion

Hello experts,
I am in the process of rewriting a small VB 6.0 application into VB.net and I really dont understand the below code.

In the code below how can I do this part in VB.net Please help

Do While Not LocalRec.EOF
                If EroleIDs.Length > 0 Then EroleIDs += ","
                EroleIDs = +"'" + Trim(Str(LocalRec(0))) + "'"
                ERolesRec.MoveNext()
            Loop




LocalRec = New ADODB.Recordset
        ERolesRec = New ADODB.Recordset
        If LocalRec.State > 0 Then LocalRec.Close()
        LocalRec.Open("Select * from JobFilters where ID='" + JobID + "'", DB(DBOffset), adOpenForwardOnly, adLockOptimistic)
 
 
ERolesRec.Open("select id FROM TypeofTypes where typeid=73 and value like '*%'", db(NumConnections), adOpenForwardOnly, adLockOptimistic)
        EroleIDs = ""
        If Not ERolesRec.EOF Then
            Do While Not LocalRec.EOF
                If EroleIDs.Length > 0 Then EroleIDs += ","
                EroleIDs = +"'" + Trim(Str(LocalRec(0))) + "'"
                ERolesRec.MoveNext()
            Loop
        End If

Open in new window

Avatar of ToddBeaulieu
ToddBeaulieu
Flag of United States of America image

EroleIDs appears to be a string variable. The intent of this loop is to build a comma delimitted list of id's .

So, the first recordset is a list of job filters for the current job (JobID variable).

Next it fetches a recordset from TypeofTypes that meet the typeif and value criteria shown.

It then clears the target list string and loops through all the rows in the job filters recordset. Before it does this, though it checks to make sure that Types were found via the EOF property. If there are some, it will enumerate the filters and for each one found, append the first column in the filter recordset. Since "*" is used, it's not possible to know what that column is from the given code. It proably ought to be tweaked to return the first column only, unless the others are used elsewhere now shown.

This code doesn't really look correct, though. If you notice the "do while" is enumerating the list of filters, but the "movenext" is advancing the TypeofTypes recordset. I can't see how this loop would EVER exit.
ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial