Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Access not closing properly via vb.net: Still in memory

vb.net 2003
Office 2003
Access not closing properly via  vb.net.

' Calling from vb.net
Public Sub ExportBrand(ByVal strName As String, ByVal strCat As String)
        ' CAN USE IF NEEDED 01292007
        ' long execution go and make excel to visible . false:  STRAIGHT CALL TO ACCESS FOR DATA
        Dim oAccess As New Microsoft.Office.Interop.Access.Application
        'Start Access and open the database.

        oAccess = CreateObject("Access.Application")
        oAccess.Visible = False
        oAccess.OpenCurrentDatabase("C:\dm2007\SkuCat.mdb", False)
        'Run the procedure
        '  oAccess.DoCmd.RunMacro(mcrName)
        oAccess.Run("CallExportG", strName, strCat)     'Clean-up: Quit Access without saving changes to the database.
        '  oAccess.CloseCurrentDatabase()
        MsgBox("Done Exporting Grainger Brand")
        oAccess.Quit()
        oAccess = Nothing
    End Sub

=============================================
While in Access this is running and closing:
Public Sub CallExportG(strName As String, strCat As String)
 ExportCombo strName, strCat
End Sub

Public Sub ExportCombo(strMfrnam As String, strCat As String)

Dim strSql As String, qd As DAO.QueryDef
Set qd = CurrentDb.QueryDefs("BrandQuerySql")

strSql = "SELECT tblCoreSkuInformation.ITEM, tblCoreSkuInformation.WWGMFRNAME, "
strSql = strSql & "tblCoreSkuInformation.WWGMFRNUM, tblCoreSkuInformation.WWGDESC, "
strSql = strSql & "tblCoreSkuInformation.RICHTEXT , tblCoreSkuInformation.SPIN, "
strSql = strSql & "tblCoreSkuInformation.REDBOOKNUM, tblCoreSkuInformation.UOM, tblCoreSkuInformation.[UOM Qty], "
strSql = strSql & "tblCoreSkuInformation.[Customer Willcall Qty], tblCoreSkuInformation.[Customer Ship Qty], "
strSql = strSql & "tblCoreSkuInformation.ALT1, tblSkuCat.[Segment Name], tblSkuCat.[Category Name]"
strSql = strSql & "FROM tblCoreSkuInformation LEFT JOIN tblSkuCat ON tblCoreSkuInformation.ITEM = tblSkuCat.[Grainger SKU]"
strSql = strSql & "WHERE (((tblCoreSkuInformation.WWGMFRNAME)='" & strMfrnam & "') AND ((tblSkuCat.[Category Name])='" & strCat & "' ));"

qd.SQL = strSql

DoCmd.TransferSpreadsheet acExport, 8, "BrandQuerySql", "C:\DM2007\Export_Template.xls", True, ""
qd.Close
Set qd = Nothing
End Sub

One instance of Access is still left iin memory  after  running these routines  ??

ASKER CERTIFIED SOLUTION
Avatar of Hillwaaa
Hillwaaa
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial