Web.configh Connection String to Local Nework Server

Posted on 2013-11-01
Last Modified: 2013-11-08
I currently have my aspx files stored on a web server with 2008 ms sql. I have no problem connecting to the ms sql on the web server using a connectstring in my web.config. My company also has a local network 2008 ms sql where I need to retrieve some data. Is it possible to create a connection string in my web.config file on the web server to connect me to my company's local network server? I understand that remote users will not have access to this data. Any help or insight would be appreciated!
Question by:pcareWI
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 333 total points
ID: 39616744
As long as there are no hardware (e.g. firewall) or software (e.g. permissions) restrictions to your application reaching the server, then you can connect to your database server wherever it resides if it is connected to a reachable network. Review the connection strings for SQL Server to determine which one makes the most sense for your environment.
LVL 15

Expert Comment

ID: 39616779
Yes it is qutie possible. In our company our web.config containts entries for 3 SQL Server Machines (none of them are on webserver)"

The main point is since you do not want to give every user of your web app permit to use the SQl Server. You need to use a generic user and Passord  Within your ASPX code(put this inof in the config file) . For example MyLogin and MyPassword and pass this info to the connectionctring when connecting to the SQL server.

Before the above you have to ASK the Sql Server Admin to provide admin rights on the proper databases on the SQl Server to this generic user(MyLogin).

Author Comment

ID: 39616791
I use the connection string below to access the local network server in my testing environment which is local as well and the connection works fine. But when I load the web.config file to the web server, I get an error which is specified below.

Connection string: <add name="TestConnectionString" connectionString="Data Source=APOLLO\MSSQLSERVER2008;Initial Catalog=AppData;User ID=Testuser; Password=user"
providerName="System.Data.SqlClient" />

Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 333 total points
ID: 39616806
Can the web server "see" the APOLLO server? You may need to confirm with your network staff and/or server admins.

Author Comment

ID: 39616807
Hi unknown_routine,
I will request that my sql server admin provide admin rights to the generic user. Do you have an example of your connectionstring that you use?

I will confirm with my admin if my webserver can see apollo.
LVL 15

Expert Comment

ID: 39617025
Here is one Server in our web config:

<!--***** DEVELOPMENT DataBase*****-->
      <add key="MyLogin" value="Provider=SQLOLEDB;Data;User ID=MyLogin;Password=MyPassword;Initial Catalog=MyDatabase;Workstation ID=A
BC_001;Command timeout=24000"/>

We have similar entries also for QA and productions databases.
LVL 15

Accepted Solution

unknown_routine earned 167 total points
ID: 39617030
Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

In your case ASk the SQl Server Admin what  the ip address of the local SQL server(APOLLO) is. Then from the Webserver machine try to ping it. If you can't, you need to contact your  network admin to make that possible.

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
T-SQL Query - Group By Year 3 32
Access #Deleted data 20 43
SQL Distinct Question 3 15
T-SQL: Need Group By to use "fuzzy logic"?? 3 23
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

733 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