473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

vb.net office xp automation and threads

I have a windows service that uses office xp automation. Here is the
code
---------------------------------------
Public Sub CAccessSnapShot()
Try
Dim objAccess As New Access.Application()
Dim vSQLText, vThreadName As String
Try
vThreadName = Thread.CurrentThread.Name
cFunctions.WriteEventLog("starting report on thread: " &
pDBType)
Dim dtSQLText As DataTable
' GET THE SQL ASSOCIATED WITH THIS REPORT
dtSQLText = cFunctions.GetSQL(pReportRefNum,
pQConnectionString)
vSQLText = CStr(dtSQLText.Rows(0).Item("SQLText"))
Dim strMDBName, strSNPName, strAccessFuncNm As String
' GET THE NAME OF THE TEMPORARY MDB AND MAKE A COPY TO
WORK WITH
strMDBName = cFunctions.GetNewFileName(".mdb")
strMDBPath = pInputFileDir + strMDBName
System.IO.File.Copy(pInputFileDir + pInputFileName,
pInputFileDir + strMDBName)
' OPEN THE NEW COPY OF THE MDB
objAccess.OpenCurrentDatabase(pInputFileDir +
strMDBName)
' GET THE NEW NAME OF THE SNAP FILE
strSNPName = cFunctions.GetNewFileName(".snp")
strAccessFuncNm = "rpt" + pReportName
' RUN THE FUNCTION FROM ACCESS TO CREATE THE REPORT
SNAPSHOT
objAccess.Run("RunReports", pReportName, vSQLText,
pOutputFileDir, strSNPName, pConnectString)
' SHUT DOWN ACCESS AND RELEASE THE COPY FROM MEMORY

objAccess.DoCmd().Quit(Access.AcQuitOption.acQuitS aveNone)
' ------
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objAccess)
' UPDATE THE QUEUE WITH THE SNAP SHOT NAME AND DELETE
THE COPY OF THE MDB
cFunctions.WriteEventLog("complete report on thread: " &
vThreadName)
cFunctions.UpdateRptComplete(pReportRefNum, strSNPName,
pQConnectionString)
System.IO.File.Delete(strMDBPath)
'RaiseEvent ThreadDone(pDBType)
Catch errorVariable As Exception
'Error trapping
cFunctions.UpdateReportError(pReportRefNum,
errorVariable.Message.ToString, pQConnectionString)
cFunctions.WriteEventLog("GPReportServer.NET-Error: " &
errorVariable.Message.ToString)

objAccess.DoCmd().Quit(Access.AcQuitOption.acQuitS aveNone)
' -----
System.Runtime.InteropServices.Marshal.ReleaseComO bject(objAccess)
Finally
RaiseEvent ThreadDone(pDBType, vThreadName)
End Try
'CType(state, AutoResetEvent).Set()
Catch
Catch errorVariable As Exception
'Error trapping
cFunctions.UpdateReportError(pReportRefNum,
errorVariable.Message.ToString, pQConnectionString)
cFunctions.WriteEventLog("GPReportServer.NET-Error: " &
errorVariable.Message.ToString)
End Try
End Sub

-----------------------------------------------------
I have a driver sub routine that creates a set of threads. Then on each
tread it calls this sub if there is a request for an access report. He
problem is if 2 or more threads are running at the same time, when the
first thread ends and issues the quit, it seems to affect all instances
of access in memory. The all stop running. How can I issue the quit to
just the thread this sub is running on???

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
0 931

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard | last post by:
Office Addins are easy in .NET. Try this from Visual Studio's main menu: File New Project "Other Projects" Extensibility Projects Shared Addin Run the wizard and you're off...
2
by: Alex Maghen | last post by:
Hi. I've seen several KBs on using .NET for MS Office Automation. But I have a particular question: I am developing a somewhat stand-alone .ASPX page which will need to do some relatively simple MS...
2
by: leodippolito | last post by:
Sirs, I have an ASP.NET application with hundreds of users accessing it. One of its features is to merge a set of Word documents that are stored in a server (basically is copy contents from doc1...
12
by: Tomas | last post by:
Hi, I have worked with VB.NET for half a year (semi-newbie). Currently I am looking around for some books for those that crossed the starting hurdle. There are too many books out there-make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.