472,977 Members | 2,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

C# Windows Service Problem

I have created a Windows Service using Visual Studio .Net 2005 and C# which
executes a series of database jobs on a time basis. I am using
SqlConnections and SqlCommand objects to connect to a SQL Server database
and execute stored procedures and query text commands. I am running into
this problem on some computers after a reboot is done. I get the following
error message when the service attempts to execute a SqlCommand:

Could not create an instance of OLE DB provider 'MSDASQL'.
OLE DB error trace [Non-interface error: CoCreate of DSO for MSDASQL
returned 0x80070005].

This seems to only be an issue on reboot because I can restart the service
and everything works fine after that.

Any help is greatly appreciated!

Thanks!


Sep 10 '07 #1
8 5751
Does it connect to a database on the same machine? perhaps the
database hasn't awoken yet... perhaps add a service dependency, or
just set a delay in the top of your service... if neither helps, look
for other likely services that might still be waking up - RPC perhaps
(which drives a lot of DTC).

Marc

Sep 10 '07 #2
"DF Dev" <jr***@newsgroup.nospamwrote in message
news:u5**************@TK2MSFTNGP02.phx.gbl...
Could not create an instance of OLE DB provider 'MSDASQL'.
OLE DB error trace [Non-interface error: CoCreate of DSO for MSDASQL
returned 0x80070005].

This seems to only be an issue on reboot because I can restart the service
and everything works fine after that.
Have you configured your windows service to have a dependency for the SQL
Server service? If not, your own service may be starting before the SQL
Server service, in which case it is necessarily not available yet.

To see the service dependencies for a particular service, go to the services
applet in your control panel, right-click and select properties on the
service in question, and open the Dependencies tab.

Nicolas
Sep 10 '07 #3
Yes it connects to a database on the same machine. I have already added
code to wait for SQL at the top of the service and I also have a dependency
for SQL Server. I am not checking RPC but I will look into that.

"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@19g2000hsx.googlegro ups.com...
Does it connect to a database on the same machine? perhaps the
database hasn't awoken yet... perhaps add a service dependency, or
just set a delay in the top of your service... if neither helps, look
for other likely services that might still be waking up - RPC perhaps
(which drives a lot of DTC).

Marc

Sep 10 '07 #4
Yes the SQL dependency is there.. Thanks.

"Nicolas Noakes" <an********@hotmail.comwrote in message
news:uc**************@TK2MSFTNGP04.phx.gbl...
"DF Dev" <jr***@newsgroup.nospamwrote in message
news:u5**************@TK2MSFTNGP02.phx.gbl...
>Could not create an instance of OLE DB provider 'MSDASQL'.
OLE DB error trace [Non-interface error: CoCreate of DSO for MSDASQL
returned 0x80070005].

This seems to only be an issue on reboot because I can restart the
service and everything works fine after that.

Have you configured your windows service to have a dependency for the SQL
Server service? If not, your own service may be starting before the SQL
Server service, in which case it is necessarily not available yet.

To see the service dependencies for a particular service, go to the
services applet in your control panel, right-click and select properties
on the service in question, and open the Dependencies tab.

Nicolas

Sep 10 '07 #5
It might getas you simply have to keep trying (with pause) until you
can connect, and not reporting success until you have succeeded, or a
certain "give up" threshhold is met. Alternatively, attempt to connect
as part of start-up, and use the service recovery options (first
failure, second failure, etc) to keep trying every minute-or-so.

Marc

Sep 10 '07 #6
The wierd thing is Marc that I have already done that. When the service
starts, it tries to connect to SQL. If it can't, it sleeps for so long then
tries again. It goes through this process of trying to connect several
times and if it can't it stops. But the service is starting right up so it
is connecting to the database just fine. But it throws the "CoCreate" error
the first time it tries to execute a command.

"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
It might getas you simply have to keep trying (with pause) until you
can connect, and not reporting success until you have succeeded, or a
certain "give up" threshhold is met. Alternatively, attempt to connect
as part of start-up, and use the service recovery options (first
failure, second failure, etc) to keep trying every minute-or-so.

Marc

Sep 10 '07 #7
"DF Dev" <jr***@newsgroup.nospamwrote in message
news:u6**************@TK2MSFTNGP02.phx.gbl...
The wierd thing is Marc that I have already done that. When the service
starts, it tries to connect to SQL. If it can't, it sleeps for so long
then tries again. It goes through this process of trying to connect
several times and if it can't it stops. But the service is starting right
up so it is connecting to the database just fine. But it throws the
"CoCreate" error the first time it tries to execute a command.

"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
>It might getas you simply have to keep trying (with pause) until you
can connect, and not reporting success until you have succeeded, or a
certain "give up" threshhold is met. Alternatively, attempt to connect
as part of start-up, and use the service recovery options (first
failure, second failure, etc) to keep trying every minute-or-so.

Marc

0x80070005 means Access Denied, that means that you are trying to
load/access the DSO provider library, but the current user has not the
appropriate privileges to do so.
Mind to post some code? Especially the connection string(s) might be
helpful. Note that connecting to SQL server and using DSO are different
things.

Willy.

Sep 10 '07 #8
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM*************@TK2MSFTNGP06.phx.gbl...
"DF Dev" <jr***@newsgroup.nospamwrote in message
news:u6**************@TK2MSFTNGP02.phx.gbl...
>The wierd thing is Marc that I have already done that. When the service
starts, it tries to connect to SQL. If it can't, it sleeps for so long
then tries again. It goes through this process of trying to connect
several times and if it can't it stops. But the service is starting
right up so it is connecting to the database just fine. But it throws
the "CoCreate" error the first time it tries to execute a command.

"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegr oups.com...
>>It might getas you simply have to keep trying (with pause) until you
can connect, and not reporting success until you have succeeded, or a
certain "give up" threshhold is met. Alternatively, attempt to connect
as part of start-up, and use the service recovery options (first
failure, second failure, etc) to keep trying every minute-or-so.

Marc


0x80070005 means Access Denied, that means that you are trying to
load/access the DSO provider library, but the current user has not the
appropriate privileges to do so.
Mind to post some code? Especially the connection string(s) might be
helpful. Note that connecting to SQL server and using DSO are different
things.

Willy.
But shouldn't it do the same thing when you restart the service manually??
It works fine when you go into Services and restart it. It just doesn't
work on boot up.

Here is some sample code:

SqlConnection CurrentConnection = new SqlConnection();
strConnectionString = @"data source=MyServer;

initial catalog=MyDatabase;

integrated security=SSPI;

persist security info=False;

Trusted_Connection=Yes";

CurrentConnection.ConnectionString = strConnectionString;

CurrentConnection.Open();

JobsCommand = new SqlCommand();

JobsCommand.CommandText = "exec sp_Test"

JobsCommand.Connection = CurrentConnection;

JobsCommand.CommandTimeout = 0;

JobsCommand.ExecuteNonQuery();
Sep 10 '07 #9

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

Similar topics

1
by: bob | last post by:
I have created a simple Windows service in VB.Net which installs fine using InstallUtil.exe to install it to, for example "c:\test", or "c:\Windows\YellowBanana", but if I install it to "c:\Program...
2
by: epaetz | last post by:
I'm getting Not associated with a trusted SQL Server connection errors on a .Net windows service I wrote, when it's running on my application server. It's not a problem with mixed mode...
2
by: Neslihan ERDEM | last post by:
Every body Hi first of all I say Why do I need Windows Service / Every Day I create XML file . I writed a XML web service And .I join this servis Windows service. I create Windows Service that...
4
by: Kris | last post by:
I have a Windows Service in C# talking to a serial port and using Remoting. It also uses several COM objects. On customer's computer the service will occassionally hang somewhere - the service...
0
by: Scott Davies | last post by:
Hi, I'm looking for some help on a small program that I'm trying to develop in VB.NET. The program I'm trying to develop needs to be able to do the following: - Select remote server -...
10
by: Ger | last post by:
I am having problems using VB.Net's Management base object on a machine hosting Windows Server 2003. I am trying to set file permissions from a Windows Service. These files may be loacted on a...
3
by: Evan Camilleri | last post by:
I have a problem for a Windows Service to login on an SQL server (different machine) - neither Windows Authentication nor SQL Authentication worked. LOGIN FAILED FOR USER sa (for example). If...
0
by: Charles Leonard | last post by:
I am having yet another issue with Windows Server 2003. This time, the web service (a file import web service) appears to run except for one odd message: "ActiveX component can't create object". ...
2
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app...
1
by: Mahesh Devjibhai Dhola | last post by:
Hi, Scenario: The webservice was developed on windows 2000 Pro and deployed previously on windows XP pro for testing. We have tested for many days. The client for that service was 30+ and...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.