Getting The Local Instance Of SQL Server Rather Than A Named InstanceJul 29, 2010
A while ago, I wrote a web-based guestbook application that wrote it's own database.
My code was very amateurish, but, as it was my very first publication, I was very happy with it. Only about a month after I'd published it did I realize I'd made a huge mistake in the code.
I've only ever connected to a specific named instance of SQL Server, and it occurred to me that, if the SQL Server instance has a different name than the one I specified, it wouldn't work.
So, since my users will probably not know what the name of the instance of SQL Server that's running is, I thought adding a field where the user can specify it would help if they do, but what if they don't? My answer was to get the local instance, regardless of name.
I tried Data Source=.local;, Data Source=.; and other variants, but nothing worked.