"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();