DB connection problem in setup for Microsoft Course 2524

G

Guest

I am working through the manual for course 2524 (Developing XML web services
using ASP.NET). It is at least 4 years old so hopeless outdated :)-) but I
think I can salvage it to still be useful. I actually tried this with just
the express editions of visual web developer, C#, and sql server 2005. I
loaded the demo web service project (Woodgrove) and launced it via the
internal web server in visual web developer. I was successful in getting the
services page to the web service but ran into a problem when I tried to
execute a web method that accessed the service's database. The exact error
was:

"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 allow remote connections. (provider: SQL Network Interfaces,
error: 26 - Error Locating Server/Instance Specified)"

After winding down the path of that error (enabling remote connections,
enabling the sql server browser, and adding exceptions in the firewall for
sql server and sql server browser) I finally realized that that was not the
problem at all. The issue was the connection string in the demo project. The
original was:

data source=.\MOC;initial catalog=Woodgrove;user id=sa;pwd=Course_2524

But attempting to connect to this as a datasource with the "sa" login failed
(though I did setup my sql server to accept either sql or windows
authentication).

I achieved a successful connection with this connection string:

Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program
Files\Msdntrain\2524\Database\Woodgrove_Data.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True

So I solved my problem. The purpose of this post, then, is to see if someone
could enlighten me on the differences between these two connection strings
including, but not limited to, these:
Why did the original use a different data source? Why did the original not
name a specific file, but instead named a catalog? Are the other parameters
in the second string new with VS2005 but now needed?
 
W

William \(Bill\) Vaughn

Well, the SA password version is simply wrong. It's wrong in any number of ways--these are but a few:
a.. Developers should not use the SA account for their applications. It leads to a host of other issues and masks the need to manage connection security correctly. The fact that this course teaches them to do so is... not good.
b.. SQL Server does not permit logging in via username/password (SQL Server Authentication) by default. It must be enabled.
c.. If you have installed SQL Server, it must be reconfigured to support SQL Server authentication and to have the SA password set to the right value.
d.. SS Authentication is not wrong in of itself but it needs to be preconfigured on the server.
hth


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top