Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:44:52+00:00 2026-06-12T02:44:52+00:00

i get this error System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException was thrown.` Why?? Kindly help

  • 0

i get this error System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException was thrown.` Why?? Kindly help me. I get this error (only when i host the website online, not in local machine).

Dim db As SqlDatabase = Connection.connection
Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click

    'Dim lblNodeID As Label = CType(Master.FindControl("lblParentId"), Label)
    Using conn As DbConnection = db.CreateConnection()
        Dim cmdInsertGroup As SqlCommand = db.GetSqlStringCommand("Insert Into CategoryGroups Values ('" & BLL.getNewGroupIDfromCategoryGroups & "','" & lblParentId.Text.Trim & "','" & txtGroupName.Text.Trim & "')")

       Try
        If fuGroupAttributes.HasFile Then
            fuGroupAttributes.SaveAs(IO.Path.Combine(Server.MapPath("~/Admin/SpecificationExcels"), lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName)))

            Dim path As String = Server.MapPath("~/Admin/SpecificationExcels/" & lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName))
            Dim strmail As String = String.Empty
            Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=Excel 12.0;"
            Dim objConn As New OleDbConnection(connectionString)
            objConn.Open()
            Dim strConString As String = "SELECT * FROM [Sheet1$]"
            'where date = CDate('" + DateTime.Today.ToShortDateString() + "')";
            Dim objCmdSelect As New OleDbCommand(strConString, objConn)
            ' Create new OleDbDataAdapter that is used to build a DataSet
            ' based on the preceding SQL SELECT statement.
            Dim objAdapter1 As New OleDbDataAdapter()
            ' Pass the Select command to the adapter.
            objAdapter1.SelectCommand = objCmdSelect
            ' Create new DataSet to hold information from the worksheet.
            Dim ds As New DataSet()
            ' Fill the DataSet with the information from the worksheet.
            objAdapter1.Fill(ds, "ExcelData")
            'My Exp
            Dim _newAttributeID As Integer = BLL.getNewAttributeIDfromGroupAttributes
            Dim _newGroupID As Integer
            conn.Open()
            Dim trans As DbTransaction = conn.BeginTransaction()
            If cbInsertInExistingGroup.Checked Then
                If gvExistingGroups.SelectedValue IsNot Nothing Then
                    _newGroupID = gvExistingGroups.SelectedRow.Cells(1).Text
                Else
                    pnlMessage.Visible = True
                    pnlMessage.BackColor = Drawing.Color.Red
                    lblMessage.ForeColor = Drawing.Color.White
                    lblMessage.Font.Bold = True
                    lblMessage.Text = "Select a Group"
                    Exit Sub
                End If
            Else
                _newGroupID = BLL.getNewGroupIDfromCategoryGroups
                db.ExecuteNonQuery(cmdInsertGroup, trans)

            End If

            For i = 0 To ds.Tables(0).Rows.Count - 1
                ds.Tables(0).Rows(i).Item(0) = _newAttributeID
                ds.Tables(0).Rows(i).Item(1) = _newGroupID
                _newAttributeID = _newAttributeID + 1
            Next
            ' Clean up objects.
            objConn.Close()
            'Dim db As SqlDatabase = Connection.connection
            Dim sqlBulk As New SqlBulkCopy(conn, SqlBulkCopyOptions.Default, trans)
            sqlBulk.DestinationTableName = "GroupAttributes"
            sqlBulk.WriteToServer(ds.Tables(0))

            trans.Commit() ' commit the transaction
            pnlMessage.Visible = True
            pnlMessage.BackColor = Drawing.Color.Green
            lblMessage.ForeColor = Drawing.Color.White
            lblMessage.Font.Bold = True
            lblMessage.Text = "Successfully Uploaded"
            'Response.Redirect("~/Admin/AddSpecifications.aspx?id=" & Request.QueryString(0))
        Else
            pnlMessage.Visible = True
            pnlMessage.BackColor = Drawing.Color.Red
            lblMessage.ForeColor = Drawing.Color.White
            lblMessage.Font.Bold = True
            lblMessage.Text = "Select an Excel File"
            'Response.Write("")
        End If
        Catch ex As Exception
        trans.Rollback() ' rollback the transaction
        pnlMessage.BackColor = Drawing.Color.Red
        lblMessage.ForeColor = Drawing.Color.White
        lblMessage.Font.Bold = True
        lblMessage.Text = "Some Error Occured"
        End Try
    End Using
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:44:53+00:00Added an answer on June 12, 2026 at 2:44 am

    Your code is a bit complicated to follow, but in this block you Exit Sub without closing the connection objConn

    If cbInsertInExistingGroup.Checked Then
        If gvExistingGroups.SelectedValue IsNot Nothing Then
            _newGroupID = gvExistingGroups.SelectedRow.Cells(1).Text
        Else
            pnlMessage.Visible = True
            pnlMessage.BackColor = Drawing.Color.Red
            lblMessage.ForeColor = Drawing.Color.White
            lblMessage.Font.Bold = True
            lblMessage.Text = "Select a Group"
            Exit Sub
    End If
    

    You should really try to refactor this huge block of code in more small units. In this way you could use the Using statement to dispose correctly of the Disposable objects like OleDbConnection, OleDbAdapter, OleDbCommand….

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error: System.Reflection.TargetException: Object does not match target type. when trying to
I get this error System.NotSupportedException: The entity or complex type 'MyModel.Team' cannot be constructed
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
When attempting to access /account/manage on the production server I get this error: System.MissingMethodException:
I get this error when i try to upload an image: OSError at /upload/
I get this error on my Ice Cream Sandwich (Android 4.0) device and emulator.
I get this error when I run the code below. I have normally used
I get this error when I use simplejson from django.utils in google app engine
I get this error in my app { error: { message: Missing client_id parameter.,
i get this error Cannot open database DataLayer.Context.MedicallexiconContext requested by the login. The login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.