This error is happening because your SQL command is taking longer than 30 seconds to execute. I would recommend using an asynchronous call to execute this command, since it is running that long. Further, I would recommend that the SQL code be put into a stored procedure so that it can be compiled and optimized, which will reduce how long it runs. However, the root issue is the command timeout when you run it via C#.
The solution is to change the SQLCommand objects CommandTimeout value from 30 (seconds) to whatever you need plus a buffer. Here is what the code would look like:
SqlCommand cmd = new SqlCommand("select * table1", connectionString);
cmd.CommandTimeout = 120;
Here is an article that talks about your error and shows how it can happen by replicating it:
http://blogs.msdn.com/b/spike/archive/2008/07/31/timeout-expired-the-timeout-period-elapsed-prior-to-completion-of-the-operation-or-the-server-is-not-responding.aspx[
^]
In there, the author changes the timeout to ten seconds. You can use similar code, only change the timeout to be something that won't error like I did above.