SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im trying to access an SQL database from a custom TimerJob, but it fails. Without hitting the Exception, it just stops. I got the exact line where it get stuck:

SqlDataReader sqlReader = sqlQuery.ExecuteReader();

whats wrong with that line? Can a Custom TimerJob access SQL Server?

share|improve this question

The short answer is yes, a custom timer job can access sql server. However in order to work out what your problem is, you'll probably need to provide us with more information. For example you may have an issue with your connection string, permissions on the database you are trying to access etc.

share|improve this answer

Make sure the user account running the Timer Service has access to SQL server and the objects you are calling from your timer job. You can find this under Services in Administrative Tools.

Try running the sql profiler over the DB to see if a connection is established and what (if any) queries were executed.

share|improve this answer

thanks for answering, I found something interesting... You can connect to SQL server, BUT, you cant use (for some weird, unknown reason) this access:

SqlDataReader sqlReader = sqlQuery.ExecuteReader();

Instead of using that, you need to use:

SqlDataAdapter da = new SqlDataAdapter(sqlQuery.CommandText, connection);

If someone knows the reason you cant use the first statement, please comment. For everyone else having the same issue, try the 2nd statement.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.