Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

A nice thing about Sql Server 2005 Express and RANU

There are some new features around SQL Server Express 2005 (SSE)
which allow you to treat your database just like a file. You can add
the .MDF file to your project and then when you go to deploy your app
it travels with it like a file so you don’t have to worry about setting
up a database on a server. This is similar to Access but with the power
of SQL Server.  I believe this is how RANU (run as normal user) is
supposed to work. Each user on the machine gets their own instance
of SQL Express.  The way RANU works is that it looks in the exe’s
current folder for the .MDF file. When you debug and build your app in
VS the exe is actually run from a subfolder so VS has to copy the .MDF
to the same location. This requires you to put the .MDF in the project
so that the project system knows to copy the file on a build. So the
“short” answer is that there will be one copy to put it into your
project folder, and then another copy to the build location on build or
debug. There is a Copy to Output Directory property on the file which
allows you to specific if you want to do the copy everytime or just
when the .mdf file in the project changes.  So at runtime if I have a 1 GB
database it is going to get copied around at that timeHowever, you can turn off this
functionality. This is also specific to the designtime features. Runtime will
work against an absolute path so you can avoid the copies if desired. It is expected
that most databases won’t be that large so it works pretty well for getting
started with the feature.  Thanks to Eric on the
Visual Basic Data Team at MS for the information on RANU! 

This entry was posted in .Net Development, Sql Development. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to A nice thing about Sql Server 2005 Express and RANU

  1. Anil says:

    what if we need to connect to Crystal report, where we need to give the connection string with servername and other stuff.

    How do tackle this at the time of deployment.
    If you have solution do let me know at anilmane@hotmail.com

  2. I have the *.sql for Pubs and Northwind, with this don’t have problem. But AdventureDB, is un *.mdf y *.ldf file, and I cann’t attach this in my SQLExpress, is there some code make this?

  3. Alex Kazovic says:

    Rlewallen, thanks for taking the time to ask the question.

    My interpretation of the answer is that although the .MDF file will be deployed on the new machine SSE will ned to be installed seperately (unless SQL Server is already installed there).

  4. rlewallen says:

    Alex, got this information back from the data team over at MS:

    I asked them: “Also, with VS2005 and Sql Server Express 2005, you can attach an .MDF
    file to a project and deploy your app so travels with it like a file
    so you don’t have to worry about setting up a database on a server.
    Does this mean SSE will not be installed on the server in order to
    access the .MDF file, and all access goes through an ADO provider? No
    SSE has to be installed, kind of like Access?”

    They responded with: “SSE must be installed under the instance name expected by the application. You can attached the .mdf to the Full SQL version, if you do this, then there will be an exclusive lock on that mdf file and you to detach it before you can use it in SSE again. Currently SQLClient provider for SSE scenarios. You can use the OLE DB provider to attach the mdf for the full SQL server.”

  5. Alex Kazovic says:

    Can you just clarify something for me? If you add a .MDF file to you project and then deploy the project to another machine is SSE automatically installed on the other machine if it’s not already installed?

Leave a Reply