Link to home
Start Free TrialLog in
Avatar of janavar
janavar

asked on

sql server problem

hi,

i have a very strange problem. i can connect to sql server 2000 which run on my local with server name like this;
      sqlConn.ConnectionString = "server=mySrv;database=msp;user id=sa;password=janavar;";
but i can not connect with this;
      sqlConn.ConnectionString = "server=127.0.0.1,1433;database=msp;user id=sa;password=janavar;";

i need this because i must use ip address.

thanks in advance...
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

the port needs to be specified like this:
 sqlConn.ConnectionString = "server=127.0.0.1;port=1433;database=msp;user id=sa;password=janavar;";

From
http://www.connectionstrings.com/?carrier=sqlserver

Connect via an IP address
      
Provider=sqloledb;Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;


DBMSSOCN=TCP/IP. This is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server.
Avatar of janavar
janavar

ASKER

to angelIII;
i am getting this exception with your solution;
System.ArgumentException: Keyword not supported: 'port'.


to ptjcb:
i am getting this exception with your solution which is
Provider=sqloledb;Data Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial Catalog=msp;User ID=sa;Password=janavar;
{"[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied."}
Run the svrnetcn.exe on that computer. It will show you the SQL Server Network Utility. Make sure that tcp/ip is enabled and the port is 1433.

Avatar of janavar

ASKER

there are Named pipes and tcp/ip in the enabled protocols list. and tcp/ip properies page 1433 is set as default port.
What is the operating system? Is that the only SQL Server instance on the local computer?
Avatar of janavar

ASKER

os: xp pro service pack 2
in the "sql server service manager" window there are mySrv and mySrv\SQLEXPRESS in combobox as server. but how can i sure how many sql server instance running on the local?
ASKER CERTIFIED SOLUTION
Avatar of ptjcb
ptjcb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janavar

ASKER

yes when i look from control panel i see sql server 2000 and 2005. and i removed 2005. now there sql server 2000 and sql server 2005 mobile [enu] developer tools. but still i cant connect, i am getting the same error.

by the way i tested these strings for another remote sql server (2005), both work fine.
Provider=sqloledb;Data Source=x.x.x.x,1433;Network Library=DBMSSOCN;Initial Catalog=msp;User ID=sa;Password=123;
server=x.x.x.x,1433;database=msp;user id=sa;password=123;


and another strange case is when i try to telnet 1433 port, i cant connect; which port it is listening i am confused :(

C:\>telnet 127.0.0.1 1433
Connecting To 127.0.0.1...Could not open connection to the host, on port 1433: Connect failed