Nancy Street Login failed '(null)'
Click to see the Site Map
HomeInfoMusicGalleryPetsGeoHobbiesGeo
Site MapWhat's NewRecent ChangesContactsServer StatisticsSite Information Home « Computers « DevBlog

Back to: Development Blog Contents

Hours are wasted trying to get an ASP.NET application to talk to an SQL Server database. The answer is so stupidly backwards and simple it makes me want to slap myself.

While creating a demonstration ASP.NET web site in late July 2004 I had to drag data out of tables in both Access and SQL Server. IIS and the Access database were on the local development workstation, but the SQL Server tables were coming from the LAN server. This was a seemingly simple scenario where an ASP.NET application on a workstation was trying to read tables on a server. All attempts to open the SqlConection produced:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection

After hours of experimenting with connection strings and permissions I could not change the error. I posted this problem into the Stanski Group and within minutes I received a phone call from Andrew C from Microsoft in Sydney who helped me arrive at the following solution:

I was not running a Domain on my LAN, so using Windows authentication was not possible. This is what wasted all of my time, as I was trying to use this type of authentication but my workstation IIS could not pass any credentials to SQL Server on my server.

Following Andrew's advice I had to revert back to the simplest of ancient authentication systems. In SQL Server Enterprise Manager on the server I right-clicked the server and in the Security properties tab selected "SQL Server and Windows". I create a standard SQL Server user with a password and give it read/write permission to the database. The connection string becomes this:

UID=xxxxx;password=yyyyy;
Trusted_Connection=false;packet size=4096;
data source='myserver';persist security info=False;
initial catalog=MyTestDatabase

Note that Trusted_Connection is false, so SQL Server does not query the operating system for credentials, they are taken from the UI and password in the connection string. After these changes my web application came to life.

A few months after I had this problem I built a new computer to act as a Domain Controller and converted the whole home/office network to be a domain. Once you do this, domain accounts can be used more liberally, including in connection strings.

Back to: Development Blog Contents


Contact Information | PGP Keys | Site Map | What's New | Visitor Book
Last Updated: 30-Nov-2008 20:28
Copyright © 1999-2007 Orthogonal Programming