473,738 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Web Site. Connecting to SQL Server. Test Connection Fine...BUT

Hello,

I have a problem that I'm hoping someone will be able to help me
resolve.

1) I have a C# Web Site in which I connect to the database: "Install
Microsoft SQL Server 2005 Express Edition" via the link on:

http://msdn2.microsoft.com/en-us/express/bb410792.aspx

This Web Site has various versions, but I use the following version:

-----------------------------------------------------------------------------------------------------------------------------------------------------
Install Microsoft SQL Server 2005 Express Edition
Microsoft SQL Server 2005 Express Edition is the free, easy-to-use,
lightweight version of SQL Server 2005. Integrated with Microsoft
Visual Studio 2005, SQL Server Express makes it easy to develop data-
driven applications that are rich in capability, offer enhanced
storage security, and are fast to deploy. SQL Server Express is free
to redistribute and can be seamlessly upgraded to more sophisticated
versions of SQL Server.

Download * (36.5 MB)
-----------------------------------------------------------------------------------------------------------------------------------------------------

2) I connect to this SQL Server version via the "Server Explorer" Tab
inside Visual Studio 2005.

Here's the connection string I am using:

Data Source=.\SQLEXP RESS;AttachDbFi lename=E:\MyDB. mdf;User ID=sa

3) When I click on the "Test Connection" command button, it states:

"Test Connection Succeeded".

4) In spite of all this, when I run the application, I get an error
on the "End Try" of a "Try Catch" in my code. This error states:

"SQL Exception was unhandled by user code. An error has occurred
while establishing a connection 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".

5) Question: Does anyone have any idea how to resolve this error.
The "Test Connection" said that it was fine, but it appears not to
be. If it is indeed a problem with "under the default settings SQL
Server does not allow remote connections", I've looked, but how do you
change these settings?

Any ideas on how to proceed would be helpful.

Thanks
Sam

Aug 31 '07 #1
2 4962

The website may not be able to see E:\mydb.mdf. (or rather the use account
the website uses)

Most people put the mdf in a relative path from the website root.
//
"SQL Exception was unhandled by user code. An error has occurred
while establishing a connection 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".//

This error is kinda like "Your car is making a noise, it may be the engine
not running well".

The remote connections part that is. If you're on the same box, then you
aren't doing remote calls.

The error is basically saying "You cannot connect to the database".

............

In 2.0 asp.net there is a special folder called "App_Data". Most people put
their database in there.

OR you can provide rights to the e:\yourdb.mdf to the account which asp.net
uses.

I'm pretty sure this is the issue.


<sa***********@ yahoo.cawrote in message
news:11******** **************@ d55g2000hsg.goo glegroups.com.. .
Hello,

I have a problem that I'm hoping someone will be able to help me
resolve.

1) I have a C# Web Site in which I connect to the database: "Install
Microsoft SQL Server 2005 Express Edition" via the link on:

http://msdn2.microsoft.com/en-us/express/bb410792.aspx

This Web Site has various versions, but I use the following version:

-----------------------------------------------------------------------------------------------------------------------------------------------------
Install Microsoft SQL Server 2005 Express Edition
Microsoft SQL Server 2005 Express Edition is the free, easy-to-use,
lightweight version of SQL Server 2005. Integrated with Microsoft
Visual Studio 2005, SQL Server Express makes it easy to develop data-
driven applications that are rich in capability, offer enhanced
storage security, and are fast to deploy. SQL Server Express is free
to redistribute and can be seamlessly upgraded to more sophisticated
versions of SQL Server.

Download * (36.5 MB)
-----------------------------------------------------------------------------------------------------------------------------------------------------

2) I connect to this SQL Server version via the "Server Explorer" Tab
inside Visual Studio 2005.

Here's the connection string I am using:

Data Source=.\SQLEXP RESS;AttachDbFi lename=E:\MyDB. mdf;User ID=sa

3) When I click on the "Test Connection" command button, it states:

"Test Connection Succeeded".

4) In spite of all this, when I run the application, I get an error
on the "End Try" of a "Try Catch" in my code. This error states:

"SQL Exception was unhandled by user code. An error has occurred
while establishing a connection 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".

5) Question: Does anyone have any idea how to resolve this error.
The "Test Connection" said that it was fine, but it appears not to
be. If it is indeed a problem with "under the default settings SQL
Server does not allow remote connections", I've looked, but how do you
change these settings?

Any ideas on how to proceed would be helpful.

Thanks
Sam

Aug 31 '07 #2
On Aug 31, 11:10 pm, samadams_2...@y ahoo.ca wrote:
"SQL Exception was unhandled by user code. An error has occurred
while establishing a connection 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".
http://support.microsoft.com/default...b;EN-US;914277
Aug 31 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6170
by: kamilla | last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100. Now I want to access that db from a W2K pc, address 10.0.0.200. I am able to ping 10.0.0.100, but I cannot connect to the db, and get error 2013. I have tried with MySQL Administrator 1.0 and also with ODBC. The db on linux has grant all on *.* to ''@'10.0.0.%' and also tried .... to root@10.0.0.200 and others seen on posted messages. I can access that db...
4
216
by: Thomas Scheiderich | last post by:
I get an error from trying to connect to my Sql6.5 server (which is why I am using Ole). It says the server doesn't exist or the password is wrong. I can't understand that because I use essetially the same connection scripts on my ASP pages and it works fine. Here is my ASP connection that works fine: ***************************************************************** Set connectionToDatabase=Server.CreateObject("ADODB.Connection")...
7
1585
by: Jon Davis | last post by:
OK I have a web app that I built that makes MANY calls to the DB in each request. The app wasn't tuned for scalability so this wasn't a problem, but time is too short to redesign how the database is accessed because the data that's being stored is time relevant and the web app will be thrown out in a few months. Since I try to separate the OleDb stuff from the business logic, I just create new database connections and trust that those...
5
1696
by: Bendik Engebretsen | last post by:
Developed this personal WEB site with the new ASP.NET 2.0 Beta: http://www.techsoft.no/bendik/ It has got this problem: After a while browsing through pictures on the site, an error occurs: 'Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.'
8
1492
by: Martin Randall | last post by:
Hi, I'm trying to get a simple dataview test page working on my hosted site. The hosted site runs ASP.Net 2.0, no problem. The test page works on my development machine, no problem... but when I upload the published site I get... System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings...
6
7775
by: Todd Brewer | last post by:
Windows Server 2000 ASP.NET 2.0 SQL Server 2000 (on a physically seperate server) I moved an ASP.NET 2.0 application from a development server to production, and am getting the following error: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection 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
3
1498
by: Phils | last post by:
Hi guys; new to asp web design; I have design a simple web site that allows our client to login and view reports we manage for them. this works fine as on our network as i can connect fine to server that the database resides on for authentication and such.
1
3758
by: Brad Isaacs | last post by:
I am working with ASP.NET 2.0 and using an SQL Server 2000 database. I am using Visual Studio 2005 and developing on my Local machine. I am working with Login controls ASP.Configuration, I wanted to move my work and needed to place it on the server. Using VS 2005 , went to BUILD -Publish Web Site Checked the box for :: Alow this precompiled site to be updatable.
1
2375
by: jobs | last post by:
I am able to access 9i and 10g Oracle DBs from other clients on my pc - sqlplus, PLSQL Developer, etc. As a simple test I just wanted to connect and access the same oracle DBs through ASP.NET on my same client ... my web config connection entry looks like this (somebody elsewhere said this was working for them): <add name="pp2" connectionString="user id=xxx;password=xxx;data
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.