[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Help with system.outofmemory error - Do While Loop

I'm sure this is something simple but I just don't see it.  I'm getting a system.outofmemory error when I execute this script.  Can someone have a look at it and tell me what I'm doing incorrectly.  
Dim dt As New DataTable
        dt.Columns.Add("Times", GetType(String))

        Dim startTime As DateTime = "12:00 AM"

        Dim row As DataRow
        row = dt.NewRow()
        row("Times") = startTime
        dt.Rows.Add(row)

        Do While startTime <> "11:30 PM"
            row = dt.NewRow()
            startTime = startTime.AddMinutes(30)
            row("Times") = startTime
            dt.Rows.Add(row)
        Loop

        GridView1.DataSource = dt
        GridView1.DataBind()

Open in new window

0
cdemott33
Asked:
cdemott33
1 Solution
 
pateljituCommented:
Whats the system configuration?

Code seems to be running fine with no error, usually this error would occur if there are too many rows to iterate through which is not the case in your code. Also is there any other code that gets execute along with this script.
0
 
cdemott33Author Commented:
I rebooted the server and it seems to have solved the problem.  Thanks for your help.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now