Solved

VB Code into VB.net confusion

Posted on 2009-05-08
2
149 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:rowmark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Expert Comment

by:ToddBeaulieu
ID: 24337394
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.
0
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 500 total points
ID: 24342703
i hope you got clear about the functionality. see the previous post.
Attached sample code in vb.net

Cheers,
M.Raja


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)
 
 
 
myConnection.Open()
 
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 + "'"
 
Loop
 
end if
 

Open in new window

0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question