473,387 Members | 1,834 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,387 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 5762
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...

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.