Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running a procedure on a loop

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
Hi

I have got some code that returns a list of all applications installed on a PC. I am now trying to run it across all PC's on my network by loading all of my PC names into a SqlDataReader and then looping through that.

What I am finding is that the procedure is being called before the last one has finished - what is the best way to prevent this?

My code that calls it is as follows:

Code:
'Look up all live PCs and laptops
        conn.Open()
        strSQL = "SELECT bwbnet_Assets.AssetName " & _
                 "FROM bwbnet_Assets " & _
                 "WHERE (AssetType=1 OR AssetType=2) " & _
                 "AND OperationalStatus='LIVE' " & _
                 "ORDER BY AssetName ASC"

        cmd.CommandText = strSQL
        Dim readerID As SqlDataReader = cmd.ExecuteReader
        While readerID.Read()
            assetName = readerID.GetString(0)
            lblStatus.Text = "Auditing " & assetName & "..." & Now.ToString
            AuditPC(assetName)
        End While
        readerID.Close()
        conn.Close()

Thanks very much

Ed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top