CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Posts
    16

    [RESOLVED] error - Exception of type 'System.OutOfMemoryException' was thrown.

    Hi all, my application occurs an error "Exception of type 'System.OutOfMemoryException' was thrown." when trying to import xlsx file to sql server.
    Any help appreciated...Please Help this is very urgent
    Code:
            strSQL = "select * from [" & ExcelSheetName & "]"
            Dim Oledbcmd As New OleDbCommand(strSQL, XLSconnection)
            Dim oledbda As New OleDbDataAdapter(strSQL, XLSconnection)
            Dim DS As New DataSet
            ProgressBar1.PerformStep()
            oledbda.Fill(DS, "DS")

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: error - Exception of type 'System.OutOfMemoryException' was thrown.

    How many records?

    Why the two data sets?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: error - Exception of type 'System.OutOfMemoryException' was thrown.

    Well - as the exception says - you're trying to do something which you haven't got memory for.
    You need to change your procedure.

  4. #4
    Join Date
    Sep 2009
    Posts
    16

    Smile Re: error - Exception of type 'System.OutOfMemoryException' was thrown.

    Yes,that's why after i deleted the dataset code, and just using data reader, the code works fine. Dataset consume much memory than data reader...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured