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 732823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:11:10+00:00 2026-05-14T07:11:10+00:00

I have developed a VB.Net code for retrieving data from excel file .I load

  • 0

I have developed a VB.Net code for retrieving data from excel file .I load this data in one form and update it back in excel after making necessary modifications in data. This complete flow works fine but most of the times I have observed that even if I close the form; the already loaded excel process does not get closed properly.

I tried all possible ways to close it but could not be able to resolve the issue. Find below code which I am using for connecting to excel and let me know if any other approach I may need to follow to resolve this issue.

Note: I do not want to kill the excel process as it will kill other instances of the excel

Dim connectionString As String

connectionString = “Provider=Microsoft.Jet.OLEDB.4.0; Data Source=” & ExcelFilePath & “;
Extended Properties=excel 8.0; Persist Security Info=False”

    excelSheetConnection = New ADODB.Connection

    If excelSheetConnection.State = 1 Then excelSheetConnection.Close()
    excelSheetConnection.Open(connectionString)
    objRsExcelSheet = New ADODB.Recordset

    If objRsExcelSheet.State = 1 Then objRsExcelSheet.Close()
    Try
        If TestID = "" Then
            objRsExcelSheet.Open("Select * from [" & ActiveSheet & "$]", excelSheetConnection, 1, 1)
        Else
            objRsExcelSheet.Open("Select Test_ID,Test_Description,Expected_Result,Type,UI_Element,Action,Data,Risk from [" & ActiveSheet & "$] WHERE TEST_Id LIKE '" & TestID & ".%'", excelSheetConnection, 1, 1)
        End If
        getExcelData = objRsExcelSheet
    Catch errObj As System.Runtime.InteropServices.COMException
        MsgBox(errObj.Message, , errObj.Source)
        Return Nothing
    End Try

    excelSheetConnection = Nothing
    objRsExcelSheet = Nothing
  • 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-05-14T07:11:10+00:00Added an answer on May 14, 2026 at 7:11 am

    You are using the old VB6 COM interfaces. There isn’t any evidence in your code snippet of you ever calling Close() on the RecordSet. You can’t call Close() on the Connection since you set it to Nothing.

    As written, Excel won’t exit until the garbage collector runs and the finalizer thread releases the reference counts on the COM interfaces. Which can take a long time if your program doesn’t exit or goes dormant after processing the data. You really should consider uplifting this code to use the classes in System.Data.Oledb so you can properly Dispose() everything when you’re done with the objects.

    The Q&D solution is to force the finalizer thread to run:

        GC.Collect()
        GC.WaitForPendingFinalizers()
        GC.Collect()
    

    Run this after you’re done using the RecordSet. It isn’t otherwise recommended.

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

Sidebar

Ask A Question

Stats

  • Questions 505k
  • Answers 505k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If your grid is single-selection, my suggestion is that you… May 16, 2026 at 3:26 pm
  • Editorial Team
    Editorial Team added an answer switch ($i) { case A: case B: case C: $letter… May 16, 2026 at 3:26 pm
  • Editorial Team
    Editorial Team added an answer Press Ctrl+. to open that menu. May 16, 2026 at 3:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have developed a VB.NET WCF service that recives and sends back data. When
I have a xml file that changed when i update some values, and i'm
I have the following web config file. I am having some difficulty in retrieving
I have developed an ASP.NET web application in Visual Studio 2008. I have an
We currently have developed an application using WCF. Our clients make connections to different
I am Java beginner. I have developed only two Java desktop applications and I
I have a WSDL generated by WCF and now this WSDL should be used
I am an asp.net web application developer and I always have used Enterprise Library
I have wrote a simple web service in .NET which return a string value.
I am a .NET Developer, but the question I am having is not related

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.