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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataTable loops

Status
Not open for further replies.

SQLScholar

Programmer
Aug 21, 2002
2,127
GB
Hey all,

I have basically the below code:

Code:
        Dim olead As New Data.OleDb.OleDbDataAdapter
        Dim dt As New Data.DataTable
        Dim AccountName As DataColumn = New DataColumn("AccountName")

        AccountName.DataType = System.Type.GetType("System.String")

        olead.Fill(dt, Dts.Variables("NewAccountList").Value)
        dt.Columns.Add(AccountName)
        Try
            For Each row As Data.DataRow In dt.Rows
                CreateAdAccount(row)
            Next

            System.Threading.Thread.CurrentThread.Sleep(300000) 

            For Each row As Data.DataRow In dt.Rows
             createdir(row)
next

The problem i am having is that in the second loop its starting off on the last element of the data table. How can i reset so it goes through the table a second time?

Many thanks
Dan


----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
The only thing I can assume is the fact you are using/declaring the same variable twice is causing it. It is just good programming practice not to do something like that. Also why do, whatever you are trying to do, in two sperate loops?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Aha.... there is a reason. There is a wait between the first loop and the second - else the second wont work!

Its doing AD stuff and requires the servers to have propigated. In the end i have used a .count style loop.

Thanks

Dan

----------------------------------------
Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Dr. Seuss

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top