Hi All,

i worked hard with following error from two weeks. when i am connecting to my sql database from client machine using vb.net following error occured. its worked for local machine.

"an error has occured while connecting to the server. when connecting to sql server 2005 ,this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.(Provider:named pipes provider,error 40-could not open a connection to SQL server)"

please help me.

Thanks in Advance!

thanks stevon,

i tried with this. but it doesn't worked. can you please give a another solution.

>sql server does not allow to remote connection.
Post your connection string code.

str="Data Source=.\sqlexpress;Initial Catalog=dbfirst;Integrated Security=True"
'or
str="Data Source=.\sqlexpress;Initial Catalog=dbfirst;User id=sa;Password=sa"

Read about MS-Sql server authentication - http://msdn.microsoft.com/en-us/library/aa905171(SQL.80).aspx

What do you mean by "its worked for local machine."?
You installed Sql server locally on a macine and your code works? how the client suppose to connect (also locally or remotely)?

Check if you change the password for the administrator.

commented: Good point. +11

thanks all,

"its worked for locally" mean i installed sql to my server and program worked for that machine. but i cant run program from other machine which connected to network(TCp/IP).at that time error message displayed.

i can connect to server machine through network normally(using "Ping" command).

please help me.

ConnectionString = "data source=SERVER;initial catalog=dbPayroll;persist security info=False;user id=sa; password=sa"

It could be a firewall problem as murid pointed out.
- What is the OS that the MSSQL is install on?

Try to:
- from any client pc, Go to control panel >> administrator tool >> Data Source (ODBC) and try to create a connection from there.

Does it succeed?

You need to have an account with full admin permissions to login form client PC
So create a account with full permission on server and use that on client machine.
Also make sure password for account is not blank
Moreover , you must do settings to allow sql server to do remote connection
Steps :
1) Enable TCP/IP in remote connections from Surface Area Configration
2) Start Browser Service
3) Add sqlserver.exe to firewall exception
For Details you can GOOGLE "Allow remote connections in sql server"
Best of luck

Shut the service down, grab your .mdf and .ldf files, and reinstall the service properly if you can't figure out the surface area configuration:

setup.exe /qb ADDLOCAL=SQL_Engine,SQL_Data_Files,SQL_Replication,Client_Components,Connectivity,SQL_SSMSEE INSTANCENAME=@@InstanceName@@ SAVESYSDB=1 SQLBROWSERAUTOSTART=1 SQLAUTOSTART=1 AGTAUTOSTART=1 SECURITYMODE=SQL SAPWD=@@Password@@ DISABLENETWORKPROTOCOLS=0 ERRORREPORTING=1 SQMREPORTING=0 ADDUSERASADMIN=1 INSTALLSQLDIR="%ProgramFiles%\Microsoft SQL Server\"

It could be a firewall problem as murid pointed out.
- What is the OS that the MSSQL is install on?

Try to:
- from any client pc, Go to control panel >> administrator tool >> Data Source (ODBC) and try to create a connection from there.

Does it succeed?

can not create odbc connection as well.what's wrong?

can not create odbc connection as well.what's wrong?

You had mentioned before that you have a MSSQL server, what is the OS of that server? Win Server 2000 or 2003 or 2008?

When you tried to create the ODBC, in the second page where it ask you "How should sql Server verify ....." there is a button "Client Configuration" click on it and check what it gives you, try to change the server name to IP address.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.