SQL Express Troubles

Published 12 May 05 04:02 PM | despos

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.
  

Comments

# Hannes Preishuber said on May 12, 2005 11:27 AM:

Hi Dino

i had the same problems and have several solutions for it
read my weblog

# DinoE said on May 13, 2005 04:08 AM:

Hi Hannes,
I just started my research from your blog post! For some reasons, Server Explorer is not working on the only machine where I've hitherto been able to successfully install SQL Express. It works on the laptop where I can't have SQLEXPRESS working. Sounds like the story of the dog biting its own tail? Yes, it is :-)

# icelava said on May 16, 2005 05:49 AM:

What kinda error do you encounter? I found an odd bug with attachment via Server Explorer
http://icelava.net/Forums/ShowPost.aspx?PostID=1018

# Javier Luna said on May 20, 2005 11:36 PM:

I believe that any DataLayer must be a simple code block, that they allow operations against DB.

That code block would not have to know on the Business Entities. Single to specialize it is to execute the operations (Store Procedures and SQL Sentences) against the engine DB (SQL, Oracle, DB2, etc.), with which this setting.

Finally, I invite to you to download the DataLayer.Primitives Public Version.

This is very cool Data Layer :)

DataLayer.Primitives - Readme!
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=1389

Cheers,

Javier Luna
http://guydotnetxmlwebservices.blogspot.com/

# john said on June 10, 2005 08:56 PM:

When I try to run sqlexpr.exe which I downloaded I get "SQLEXPR.EXE is not a valid Win32 application" What now??

Leave a Comment

(required) 
(required) 
(optional)
(required)