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))) + "'"

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))) + "'"
        End If

Open in new window

Who is Participating?
raja_ind82Connect With a Mentor Commented:
i hope you got clear about the functionality. see the previous post.
Attached sample code in vb.net


Dim connString As String = ConfigurationManager.ConnectionStrings("ORACLE_LOCAL_DB").ConnectionString
Dim myConnection As New OleDb.OleDbConnection(connString)
Dim strQuery As String = "Select * from JobFilters where ID='" & JobID & "'"
 Dim strQuery2 As String = "select id FROM TypeofTypes where typeid=73 and value like '*%'"  
Dim myCommand As New OleDb.OleDbCommand(strQuery, myConnection)
Dim myCommand2 As New OleDb.OleDbCommand(strQuery2, myConnection)
Dim myDataReader As OleDb.OleDbDataReader
Dim myDataReader2 As OleDb.OleDbDataReader
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
myDataReader2 = myCommand2.ExecuteReader(CommandBehavior.CloseConnection)
if myDataReader2.Read() then
Do While (myDataReader.Read())
 If EroleIDs.Length > 0 Then EroleIDs &= ","
	EroleIDs &= "'" & (myDataReader.Item(0).tostring + "'"
end if

Open in new window

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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.