Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADODB.Connection as an NT service?

Status
Not open for further replies.
Aug 6, 2002
37
US
Does anyone know of anything that would cause an ADODB connection to choke when trying to run a script as a service on NT, with SRVANY?

I have a script that parses a file, extracting some data, then inserts this data into an Access 2000 database. The script works great when run manually, but it needs to run continuously, as the data is updated every 10 minutes, and I don't want to stay logged in on the system it is running on. So, I'm trying to get it to run as a service.

Here is the relevant portion of my code:
Code:
	Set oDB = CreateObject("ADODB.Connection")
	Set oRS = CreateObject("ADODB.Recordset")
	oDB.Open "C:\pathto\database.mdb"
	' All the following ad... keywords have been prev declared as const
	oRS.Open "tblEth0", oDB, adOpenKeyset, adLockPessimistic, adCmdTable
	oRS.AddNew aFlds, aData ' Arrays containing the fields and data
	oRS.Update
	oRS.Close
	If oRS.State = adStateOpen Then
		oRS.Close
	End If
	If oDB.State = adStateOpen Then
		oDB.Close
	End If
	Set oRS = Nothing
	Set oDB = Nothing

I've tried various connection strings with both DSN and DSN-less connections, again it works when run manually, but chokes as a service.

SRVANY is installed and the registry has been edited to call WSCRIPT as the Application (I also tried using CSCRIPT) and pass the script as the AppParameter. In the service, I'm using an account with admin privelege (and logon as service right).

When I start the service, the script runs but the DB connection does not get opened. I added some error handling to e-mail me the error and what I'm receiving is:

Error number -2147467259, Unspecified error

with DSN and DSN-less connections it is:

Error number -2147467259, [Microsoft][ODBC Microsoft Access Driver] Disk or network error.

I've run debug (with the //x option) as System, in interactive mode. oDB doesn't pickup the same connection string as it does when run manually (Extended Properties and so forth). Unfortunately, I can't get to the debug when running as the specified user (no interactive mode).

If anyone has done this before or would like to experiment with this, I would greatly appreciate any feedback or advice.

TIA,

~ jmcallister

 
JMcAllister,

Why not use the AT command and have it re-submit every ten minutes?

fengshui_1998
 
fengshui_1998,

Do you have an example of configuring AT to run every 10 mins.? AFAIK, AT will only schedule a job for a specific time each day, I'd need to have 144 AT jobs to get it to run every 10 mins. throughout the day... One option I'm looking into is some other scheduler program (?), although a service would be preferred and theoretically should work.

~ jmcallister
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top