views:

42

answers:

2

Hi , I have a windows 2008 r2 x64 enterprise edition + sql server 2008 r2 datacenter edition from its local computer I can make connection to the sql server with sqlClient in C# and here is my connection string looks like :

using (sqlconnection cn = new sqlconnection("Data Source=myServerIPAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;"))
{

cn.open();  //I'll get error here from remote
using (sqlcommand cmd = new sqlcommand("sql",cn))
{
 //some code here
}

}

but with exact above code from a remote computer I'll get this error :

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

but when I change above code to oledb everything works fine. respectively the connection string for oledb gonna change and this is my oledb connection string :

Provider=SQLOLEDB;Data Source=myserverIP;Password=password;User ID=sa;Initial Catalog=catalog

note : I've tried this http://www.connectionstrings.com/sql-server-2008 also but no difference

+1  A: 

Hai, please set Connection Timeout attribute of your connection string .

Vyas
as connectionstrings.com said there is no timeout attr exist in connection string for sql server 2008.but anyhow I've done what you've told here and thanks it works but there is a bigger problem : it is slow as hell!!! where as oledb connection is too fast.I've read somewhere that sqlclient is way faster than oledb but in reality it is totally reverse.do you have any idea about it?regards.
austin powers
I think problem with Sql server .Create yourself another user with the correct priveledges of user ID sa.
Vyas
I'm using "sa" in my connection string and sa has full privileges over my desired catalog I don't have any idea of how to make any further changes , can you advise?thanks
austin powers
You can create new user in windows authentication mode or SQL Server Authentication. First go to your database->security->New User
Vyas
A: 

Is TCP/IP an enabled connection protocol for the Sql-Server? You can check this with the Sql Server Configuration Manager under "Sql Server Network Configuration".

naacal
TCP/IP is enabled also.even after connection is created retrieving data is damn slow.
austin powers