473,508 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

All of a sudden CopyFromRecordset does not work running as a Windows Service

3 New Member
I have a very strange problem. I have written a Windows Service with VS2003 in vb.net. This service does some calculations and after that it needs to produce some Excel reports by getting data from an Oracle database.
This has been working fine for two years and it still is working fine in our production environment. But after installing a new test server the problems started.

I did many tests but there is something strange. When I start the application, not as a service but, as a Win Form Application it all works as it has to work. So the interactive user can produce the Excel reports. When I switch back to run the software as a Windows Service I’m having the troubles again.

These troubles were: Cannot create ActiveX component. This I solved by changing the Launch and Activation Permissions of the Microsoft Excel Application DCOM object.
But now I’m having another problem instead!

I receive an Access is denied while trying to do a CopyFromRecordset. See the code below:
Expand|Select|Wrap|Line Numbers
  1.  
  2. myADOrs = New ADODB.Recordset
  3. myADOrs.Open(strSQL, myADOconn)
  4.  
  5. If myADOrs.EOF = True Then
  6.    .Range("A7").Value = "Error retrieving the data"
  7. Else
  8.    Try
  9.       Console.WriteLine(“#records: ” + myADOrs.RecordCount.ToString)
  10.       .Range("A7").CopyFromRecordset(myADOrs)
  11.    Catch ex As Exception
  12.       Console.WriteLine(ex.Message)
  13.    End Try
  14. End If
  15.  
While running as a service the #records gives a -1. Strange because it passes myADOrs.EOF. I assume that the Access Denied error is thrown because the Recordset is empty. After logging the SQL statement I executed the statement in TOAD. This gave me the result I needed.

To solve this I tried another ODBC driver. I used to use the Microsoft ODBC Driver for Oracle, but I now tried the Oracle ODBC Driver. This gave me the following error: Specified driver could not be loaded due to system error 126 (Oracle ODBC Driver).

At first I thought it might be the fact that the data in the recordset was too long. 744 rows by 50 columns. But for another query in the same report I receive only 8 rows by 8 columns. I want to use the CopyFromRecordset method because this is the fasted way to copy a large amount of data into an excel sheet.

As far as I can see nothing is wrong with the code, because it used to work, the code has not been changed, as an interactive user my methods work fine. Only while executing the methods as a Windows Service they do not do what they need to do.

Does anyone have an idea where to look or what to do to solve the problem? If you need extra information please let me know.
Oct 19 '07 #1
3 2109
kenobewan
4,871 Recognized Expert Specialist
Tell us about the new test environment. How does it differ from the production?
Oct 19 '07 #2
Cor Pruim
3 New Member
Tell us about the new test environment. How does it differ from the production?
The test environment is just a Windows 2003 server with an Oracle client installed. There are two ODBC connections. One ODBC connection to the test environment and one ODBC connection to the production environment. The ODBC connections are only used with an ADODB connection.

The service is running under a domain account with special rights. This domain account is in the local administrator group on the server. Also this account has the rights to Log on as a service.

Installations are done by a standard installation procedure, because we want all the servers to be configured the same way. I have done this several times. There are no special configurations on the server, the service or other software on the server. Our test server needs to be very representative for our production environment.

The only thing I can think of is that there are more updates on a new installed server. And that the test server differs from our production server in that way.
Oct 19 '07 #3
kenobewan
4,871 Recognized Expert Specialist
Our test server needs to be very representative for our production environment.
Just checking :). At first glance it appears to be a referencing or versioning problem. Are you running the same version as production? Once again I am sure you are as your processes are sound. You have changed permissions so the environment is not identical from this perspective. If you decide to go the odbc path this article may help:
Use CopyFromRecordset With ODBC Recordsets
Oct 20 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
281
by: BBM | last post by:
I am new to .Net. I have a Windows service in C#. It is going to use another .Net component (DLL) made by a 3rd party company. If I start my program as an app with that DLL in the same directory,...
4
415
by: Madestro | last post by:
Hi guys, I have a little problem. I have a class that uses Windows API to capture a snapshot of the screen. I have this class in a library that I include in my projects. When I try to use...
0
1434
by: Ly Lam | last post by:
I can install/register a service application (one exe file) as different Windows Services. How can I get the EventLogs for each process to write entries under different sources? The eventlog...
1
3374
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL...
1
323
by: Stuart Nathan | last post by:
I am new to these newsgroups, and wish to ask a question on running Windows Service. Which newsgroup should this be addressed to?
5
4504
by: JM | last post by:
I have created a Windows Service which uses xml file as a data source. The service is running on .NET 2.0 and uses LocalSystem account. It was running fine but now it has started locking the xml...
0
1261
by: anupamak | last post by:
Hello, I am developing an application in VC++.Net and windows xp using the setupapi, which has to work as windows service. Actually, in the beginning, my application was developed in VC++.Net,...
5
8945
by: =?Utf-8?B?cnZhbmdlbGRyb3A=?= | last post by:
Hello, I have a problem with our OnlineBackupService.exe. This is a Windows Service which is built in .Net 1.1 and basically grabs files from the file system and will try to upload them using...
0
1858
by: cosmo | last post by:
Hello, I would like to develop a: - Windows Service for doing specific Tasks - Web Service as a communication gateway between the Windows Service and a ASP.NET Website - ASP.NET Website The...
0
7225
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
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
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...
1
7046
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
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5053
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...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.