SQL Express Troubles
It took me one day to install SQL Express and make full sense of it. This is mostly due to the fact that I have no idea to wipe out my machine to make room for it--I'm sure that with a clean install of Beta 2 things would have worked much better--but that's another story.
I don't know if there's a way to snoop into aspnetdb from within VS 2005. If there's one, though, either it doesn't work on my machine or I haven't been able to find it yet. I'm posting this information with the hope it helps somebody to fix things more quickly.
SCENARIO:
I have SQL Express installed with an instance name of MySqlExpress (not the default name) and an ASP.NET 2.0 application that is willing to use the personalization provider. As you know, Beta 2 dropped the Access database which was good for quick testing and demos and replaced it with aspnetdb.mdf which requires SQL Express. By default all providers use that MDF file as the storage medium and go to it through the LocalSqlServer connection string defined in machine.config. To make it accept a non-default name for the product instance I had to tweak machine.config to replace the default name (SQLEXPRESS) with my own. (A less intrusive approach entails using the app's web.config file, but I'm writing code for my next Programming ASP.NET 2.0 book(s) so a modified web.config would have forced readers to tweak code before running.) Now that everything works well and data is correctly read and saved to the MDF file, another problem shows up.
PROBLEM:
How can I snoop into the contents of aspnetdb.mdf? It was easy with Access or SQL Server databases in Beta 1. It would probably as much easy in Beta 2 if I could rely on a clean and perfect installation. I see that MS released SQL Express Manager, a lightweight tool for SQL Express that resembles Query Analyzer. Any way I can attach my MDF file to that tool?
SOLUTION:
When I have a database problem I usually take some time to bother my friend Fernando Guerrero (Solid Quality Learning). He brought me to see the light. The idea is attaching the MDF file of choice to SQL Express Manager and then go through the interface of the tool.
CREATE DATABASE ASPNetDb
ON (FILENAME = 'C:\Inetpub\wwwroot\ProAspNet20\App_Data\aspnetdb.mdf')
FOR ATTACH;
Now the application specific aspnetdb.mdf file is visible through SQL Express Manager (after a refresh).
TIPS:
- If you want to snoop into the profile data, run SELECT * FROM aspnet_profile
- If you want to make sure that the one displayed is the right database (who knows with file names), use sp_helpdb aspnetdb
I am happy now. But I would like to know if there was a simpler way out.