473,411 Members | 2,184 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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=.\SQLEXPRESS;AttachDbFilename=E:\MyDB.mdf;U ser 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 4933

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.googlegr oups.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=.\SQLEXPRESS;AttachDbFilename=E:\MyDB.mdf;U ser 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...@yahoo.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
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...
4
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...
7
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...
5
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: ...
8
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...
6
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:...
3
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...
1
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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...

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.