DF Dev said:
Willy Denoyette said:
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.
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();
Above code cannot throw the exception as you initially posted....
<Could not create an instance of OLE DB provider 'MSDASQL'.
OLE DB error trace [Non-interface error: CoCreate of DSO for MSDASQL
returned 0x80070005].
/>
above code connects to SQL Server using the SQLClient provider, the
error message refers to the OLEDB provider 'MSDASQL' which is an
unmanaged COM provider.
What exactly is "sp_Test" doing here?
Does MyServer refers to a local instance?
What's the identity the service is running under?
Willy.
I don't use an OLEDB provider anywhere in the program..
Something must use OLEDB, aren't you refering to Linked Servers in the
SP's?
I only use the
SQLClient provider so I don't know.
The error message refers to the OLEDB provider for DSO, that's why I said
that the code you posted is not the source of the error message.
And I just used "sp_Test" as an example
to show how it is executing stored procedures.
So sp_Test is a fictive SP?
This same code executes a
bunch of stored procedures stored in a datatable.
Here is the actual line of code: JobsCommand.CommandText = "exec " +
JobStepDataRow["Command"].ToString();
Check the SP's, they must be connecting, using the OLEDB provider
'MSDASQL', to some 'linked' server (local or remote).
Yes, MyServer refers to a local instance.
Yep.
I'm not sure if this answers your question about the identity the service
is running under or not but the service runs under the LocalSystem
account.
Keep in mind that "LocalSystem" has no network access privileges.
Willy.