[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Trouble connecting asp.net app to remote sql server

Posted on 2008-11-03
Medium Priority
Last Modified: 2013-11-26
I have an asp.net app written in vs2008 using vb.net. I'm attempting to connect to a sql server 2005 DB that's on another machine. All's well when I connect to the server on the development machine.

In the tcp/ip property pages, there are ip addresses given for IP1 and IP2, but they are different from the machine IP address.  which one should be in the connection string,  

and does someone have an example of a connection to connect to a remote sql server, so far, among the many I've tried are:

' Dim builder As New SqlConnectionStringBuilder
' With builder
'.DataSource = "\Server\Name"                                                     'Error 26

'.DataSource = "\Server"                                                        'Error 26

' .DataSource = "tcp:\\" ' TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)"

'.DataSource = "tcp:\\\Server\Name"                                                  ' TCP Provider, error: 0 - No connection could be made because the target machine actively refused it.)"

'.DataSource = "np:" ' provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"

'.DataSource = "np:\\.\pipe\MSSQL$HCSERVER\Sql\query" ' error: 26 - Error Locating Server/Instance Specified)"

'.DataSource = "lpc:" 'error: 41 - Cannot open a Shared Memory connection to a remote SQL server)"

'.DataSource = "lpc:\SAMSSQL\HCSERVER" error: 41 - Cannot open a Shared Memory connection to a remote SQL server)"

'.DataSource = "lpc:\SAMSSQL" error: 41 - Cannot open a Shared Memory connection to a remote SQL server)"

'.DataSource = "np:\\\\.\pipe\MSSQL$SAMSSQL\HCSERVER\Sql\query" ' Named Pipes Provider, error: 5 - Invalid parameter(s) found)"

'.DataSource = "np:\\" ' error: 25 - Connection string is not valid)"

'.DataSource = "tcp:\\" ' error: 25 - Connection string is not valid)"

'.DataSource = "tcp:\\\SAMSSQL\HCSERVER" 'error: 25 - Connection string is not valid)"

also I set
IntegratedSecurity = True
InitialCatalog = "Name"
UserID = "UID"
Password = "Password"'

and at times have used AttachDBFileName = "path of the file"

Any thought on why I'm having so much problems connecting?

Thanks in advance.

Question by:jbh_blue
  • 4
  • 3
LVL 13

Expert Comment

ID: 22870413
You can get the connection string here

You can also use SQLConnectionStringBuilder class to create the connection string
LVL 83

Expert Comment

ID: 22875450
1) You are setting the integrated security to true as well as supplying user name and password.
2) Why do you need to supply the protocols and ip address? "Data Source=TheDeveloper" should suffice for default instance and "Data Source=TheDeveloper\SQLEXPRESS" should be used for a named instance with name being SQLEXPRESS.
3) Do you have the client protocols enabled in the SQL Server network configuration wizard?
4) Do you have remote connections enabled in the SQL Server Surface Area Configuration?
5) Do you have the SQLBrowser service enabled and running on the SQL Server?

Author Comment

ID: 22876829
1) I've removed  the integrated security setting.

2) I got the advice about using the ip address from another poster, but it doesn't seem to make any difference.

3) I'm not sure what this is but am looking for it. It's not on my menu options.

4) Yes, I have Shared Memory, Named Pipes, and TCP/IP enabled.

5) Yes

I removed the integrated security property, and added the server name and instance as DataSource and was able to connect successfully, (or at least it seems)
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 22876868
My suggestion helped you and you still are closing the question without giving any points?

Author Comment

ID: 22876873
TechTiger007 and CodeCruiser, thank you both very much.


Author Comment

ID: 22879888
Code Cruiser, I gave you points.

Author Closing Comment

ID: 31512844

Dude, I gave you points (350) and (150) to Tech Tiger, for him helping me with www.connectionstrings.com and the stringbuilder.

I'm new to this site and if somehow I screwed up and you didn't get your points, let me know and tell me who to contact and I'll do my best to make sure you get your credit. But I specifically was given a screen on how to split the points between you two.

Again,  Many thanks,

LVL 83

Expert Comment

ID: 22880369
Its alright now. I just received the points now.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question