Usually this type of problems (in many cases) are caused by different SET configurations. When SSMS opens a connection to the database, it automatically configures some SET options. You can view/change the default options from Tools > Options > Query Execution > SQL Server > ANSI and Advanced tabs.
Similarly, most client libraries (ADO.NET, OLEDB, ODBC etc) configure some SET options when a connection to the server is established. In most cases the performance difference you are seeing is caused by one of these.
In the same way, most client libraries have a time out option. If you are using ADO.NET, the default is 30 seconds. So if the query takes more than 30 seconds, the operation will time out. On SSMS, the default query timeout is 'unlimited' seconds. If you are using ADO.NET, I would suggest you increase the query timeout and retry.
Meanwhile, it is also important to check why the query takes 2 minutes. It might need some optimization efforts.
commented on Oct 15 2011 9:48PM