OpenCurrentDatabase fails in Access 2000

Z

Zachariah

Part of a Windows Service app I created in .NET 2003 has
the following code:

Dim stOutPath As String
Dim stTableName As String
Const strDBPath As String = "C:\test_be.mdb"

acApp = New Access.Application
With acApp
stTableName = "tblTest"
stOutPath = "C:\IN\test.txt"
.OpenCurrentDatabase(strDBPath)
.DoCmd.TransferText(stTableName, stOutPath)
.CloseCurrentDatabase()
End With

acApp.Quit()
acApp = Nothing

This code creates an Access application object, does an
import from a text file (stOutPath) and generates an
Access table (stTableName). This service functions on my
development machine which is running Access 2002. However
it fails to run on my production machine which is running
Access 2000. Does anyone know why this would be? I'm
certain file to be imported exists and that the Access
Application object is being created but then
the .OpenCurrentDatabase(strDBPath) fails. I just want to
rule out anything on the .NET side
 
P

Paul Clement

¤ Part of a Windows Service app I created in .NET 2003 has
¤ the following code:
¤
¤ Dim stOutPath As String
¤ Dim stTableName As String
¤ Const strDBPath As String = "C:\test_be.mdb"
¤
¤ acApp = New Access.Application
¤ With acApp
¤ stTableName = "tblTest"
¤ stOutPath = "C:\IN\test.txt"
¤ .OpenCurrentDatabase(strDBPath)
¤ .DoCmd.TransferText(stTableName, stOutPath)
¤ .CloseCurrentDatabase()
¤ End With
¤
¤ acApp.Quit()
¤ acApp = Nothing
¤
¤ This code creates an Access application object, does an
¤ import from a text file (stOutPath) and generates an
¤ Access table (stTableName). This service functions on my
¤ development machine which is running Access 2002. However
¤ it fails to run on my production machine which is running
¤ Access 2000. Does anyone know why this would be? I'm
¤ certain file to be imported exists and that the Access
¤ Application object is being created but then
¤ the .OpenCurrentDatabase(strDBPath) fails. I just want to
¤ rule out anything on the .NET side

I don't know what kind of error you are getting but if I had to guess I would say it's probably a
permissions related issue.

The account under which the service is executing must have read/write/create/delete access to the
specified file or folder where the file resides.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
P

Paul Clement

¤ I don't know which error it is either. All I can do is
¤ throw in code to make log entries and that's how I know
¤ it's failing on the OpenCurrentDatabase line. The service
¤ is running with Administrator rights so it shouldn't be an
¤ authentication issue.

Couple of things you can do to troubleshoot this problem:

1) Check the System Event log to see if there are related errors.

2) Track the errors on your production machine using the Filemon utility
(http://www.sysinternals.com/ntw2k/source/filemon.shtml)


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top