<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server Express WebLog : Samples</title><link>http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx</link><description>Tags: Samples</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>FAQ: Error creating a Service-based database in Visual Studio 2008 SP1</title><link>http://blogs.msdn.com/sqlexpress/archive/2008/10/02/faq-error-creating-a-service-based-database-in-visual-studio-2008-sp1.aspx</link><pubDate>Fri, 03 Oct 2008 03:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974679</guid><dc:creator>sqlexpress</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/8974679.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=8974679</wfw:commentRss><description>&lt;P&gt;A few of you have run into problems when trying to add a new Service-based database to your project in Visual Studio 2008 SP1. This problem has been &lt;A href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361718&amp;amp;wa=wsignin1.0" mce_href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361718&amp;amp;wa=wsignin1.0"&gt;reported&lt;/A&gt; to Microsoft Connect and the Visual Studio team is working on a fix, but I thought I would provide some details on a workaround in the meantime. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What's the problem? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;This issue occurs when you have Visual Studio 2008 SP1 (any edition) and SQL Server 2008 Express x64 installed. This won't happen if you have the 32bit version of SQL Express installed. You know you've hit the issue when you see this error: &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: &lt;A href="http://go.microsoft.com/fwlink/?LinkId=49251" mce_href="http://go.microsoft.com/fwlink/?LinkId=49251"&gt;http://go.microsoft.com/fwlink/?LinkId=49251&lt;/A&gt; &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;The problem is caused by an error when checking the registry to verify that SQL Express is actually installed; it's installed, but Visual Studio doesn't think it's installed. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Two ways to work around the problem &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The easy way out is to uninstall the 64bit version of SQL Express and replace it with the 32bit version installed in the WoW. You can download this version from the &lt;A href="http://www.microsoft.com/express/sql/download" mce_href="http://www.microsoft.com/express/sql/download"&gt;Express website&lt;/A&gt;. If you're fiercely devoted to the native 64bit installation, or you just don't like taking the easy way out, there is another option... &lt;/P&gt;
&lt;P&gt;Congratulations on boldly accepting the challenge to stick with the native 64bit version of SQL Express in the face of this error. In order to "trick" Visual Studio into working with a database on this architecture of SQL while still preserving the expected behavior of how the database works, we're going to have to plumb the depths of working with a User Instance in order to create the database manually, add the existing database to the project and then "hook it up" once it's there. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Create the Database &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;To perform this part of you're task you'll need to connect directly to the User Instance with the client tool of your choice. I've already posted &lt;A href="http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx" mce_href="http://blogs.msdn.com/sqlexpress/archive/2006/11/22/connecting-to-sql-express-user-instances-in-management-studio.aspx"&gt;instructions on how to do this&lt;/A&gt;, so check those out first to get a connection to the User Instance. Once connected, we need to create a database in the same folder as the project you want the database to live in. You can do this using the standard UI dialogs in Management Studio by right-clicking on the Databases folder and selecting New Database. Once you have the dialog open, give the database a name and set the file path to the folder where your project lives. You can also do this in T-SQL if you'd like, here is a sample of the statement that would do this: &lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;CREATE DATABASE database1 &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;ON PRIMARY &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 54pt"&gt;&lt;EM&gt;(NAME = database1, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 54pt"&gt;&lt;EM&gt;FILENAME = N'C:\Users\&amp;lt;username&amp;gt;\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\database1.mdf', &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;SIZE = 10MB, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;MAXSIZE = 50MB, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;FILEGROWTH = 10%)&amp;nbsp;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;LOG ON &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 54pt"&gt;&lt;EM&gt;( NAME = database1_log, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 54pt"&gt;&lt;EM&gt;FILENAME = N'C:\Users\&amp;lt;username&amp;gt;\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\database1_log.ldf', &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;SIZE = 10MB, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;MAXSIZE = 50MB, &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;FILEGROWTH = 10%) &lt;/EM&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 27pt"&gt;&lt;EM&gt;GO &lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;As you can see, this is a normal CREATE DATABASE statement where I've specified the FILENAME argument to be the project folder for my project. Just replace the &amp;lt;username&amp;gt; place holder with your user name and your ready to go. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="COLOR: red"&gt;&lt;STRONG&gt;Important&lt;/STRONG&gt;&lt;/SPAN&gt;: Once the database has been created, you need to &lt;SPAN style="TEXT-DECORATION: underline"&gt;detach it from the User Instance&lt;/SPAN&gt; before you go onto the next step or you're&amp;nbsp;in for trouble later. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Adding the database to your VS project &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Make sure you've detached the database after creating in the previous section. (I told you it was important.) Back in Visual Studio you can now add the database to the project. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;On the Project menu, select Add Existing. &lt;/LI&gt;
&lt;LI&gt;In the File Open dialog, navigate to the project directory select the database you created. (You may need to change the file type being shown so that you see the Data Files in the dialog.) &lt;/LI&gt;
&lt;LI&gt;Select the database and click Add. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;You'll get the same error that got us here in the first place. Ignore it! Hit OK as if all is right with the world and you'll see that the database was added to the project, take that foolish error message. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Hookin' the database up &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;At this point your database is in your project, but we want to take the final step to make it just like it would have been if you did this using the Add New Item | Service-based Database method. Add New Item, in this case, would have automatically dropped you into the DataSet wizard, so lets create one now. &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;On the Data menu, select Create New Data Source. &lt;/LI&gt;
&lt;LI&gt;In the Data Source wizard, select Database and click Next. &lt;/LI&gt;
&lt;LI&gt;Click the New Connection button. &lt;/LI&gt;
&lt;LI&gt;In the Add Connection dialog, click the Browse button. &lt;/LI&gt;
&lt;LI&gt;Select the database you created at the beginning and click Open. (If you didn't detach it like I told you to, this is where you're going to run into trouble. Go ahead and detach it now, I'll wait…) &lt;/LI&gt;
&lt;LI&gt;If you don't trust me, click the Test Connection button. &lt;/LI&gt;
&lt;LI&gt;Click OK. &lt;/LI&gt;
&lt;LI&gt;Back in the Data Source Configuration Wizard, click Next. &lt;/LI&gt;
&lt;LI&gt;Accept the option to save the connection string, feel free the change it to something that makes sense to you, and click Next. &lt;/LI&gt;
&lt;LI&gt;After VS scans the database and discovers it's empty, click Finish. &lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;You've now got a spankin' new DataSet in your project that's connected to your database. You can work with the database as you would expect, for example you could use the Server Explorer/Database pane to add new objects to the database which you could then add to your DataSet. Like I said, it's not the most straight forward workaround, but if you only need to create one database,&amp;nbsp;this will take a lot less time than&amp;nbsp;uninstalling the 64bit version and replacing it with the 32bit version. Hopefully VS will release a fix for this issue soon; go over to MS Connect and &lt;A href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361718&amp;amp;wa=wsignin1.0" mce_href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361718&amp;amp;wa=wsignin1.0"&gt;cast your vote&lt;/A&gt; to show that this issue has affected you. The more people affected, the better the chance for a fix. &lt;/P&gt;
&lt;P&gt;- Mike &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8974679" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>DIY SQL Express SP2 Bootstrapper</title><link>http://blogs.msdn.com/sqlexpress/archive/2007/08/23/diy-sql-express-sp2-bootstrapper.aspx</link><pubDate>Fri, 24 Aug 2007 02:41:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4533076</guid><dc:creator>sqlexpress</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/4533076.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=4533076</wfw:commentRss><description>&lt;p style="margin-left: 22pt"&gt;I've waited far too long to communicate this disappointing news to everyone, so here it is…
&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;I'm not going to be releasing the SQL Express SP2 Bootstrapper manifests that I had discussed in a long ago blog &lt;a href="http://blogs.msdn.com/sqlexpress/archive/2007/02/20/sql-server-2005-sp2-has-been-released.aspx"&gt;posting&lt;/a&gt;. I'll spare you the sob story of my efforts to create this; suffice it to say that some requirements arose that complicated an official release and priorities changed over time. If you work in the software industry you know how it goes. So that brings us to…
&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;&lt;strong&gt;My feeble backup plan
&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;Most of the complications (ok, all of them) that I ran into were related to packaging up the manifests so they could be downloaded and installed. (Seriously, it's a long story, so don't ask.) The manifests themselves are pretty straight forward and only required some minor tweaks of the existing RTM manifests. There is nothing to stop me from sharing those updates with you in this blog and giving instructions on how to use them.
&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;&lt;strong&gt;DIY SQL Express Bootstrapper
&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;Technically, the bootstrapper, or the VS Generic Bootstrapper as I like to call it, refers to the technology created by the Visual Studio team to allow any developer to deliver specific sets of functionality as prerequisites that can be checked for and automatically installed by both ClickOnce and MSI based installers built with VS. The framework for building your own prerequisite is documented on MSDN in the topic &lt;a href="http://msdn2.microsoft.com/en-us/library/ms165429(VS.80).aspx"&gt;Adding Custom Prerequisites&lt;/a&gt;. A more end to end treatment of the technology was printed in MSDN magazine back in 2004 in the article &lt;a href="http://msdn.microsoft.com/msdnmag/issues/04/10/Bootstrapper/"&gt;Use the Visual Studio 2005 Bootstrapper to Kick-Start Your Installation&lt;/a&gt;. These are both recommended reading for anyone delving into the land of creating a bootstrapper manifest. Feel free to take a look at those article now if you want, I'll wait until you're done.
&lt;/p&gt;&lt;p style="margin-left: 22pt"&gt;The SQL Express bootstrapper is composed of five pieces:
&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The product manifest that describes the non-localized pieces of the package
&lt;/li&gt;&lt;li&gt;The package manifest that describes the localized pieces of the package, such as the messages associated with specific error codes.
&lt;/li&gt;&lt;li&gt;A license file containing the SQL Express EULA.
&lt;/li&gt;&lt;li&gt;A custom executable that Microsoft created to check to see if SQL Express is installed or not.
&lt;/li&gt;&lt;li&gt;&lt;div&gt;The actual SQL Express installation package.
&lt;/div&gt;&lt;p&gt;All five of these pieces is available to you, so you can create your own SP2 bootstrapper by creating a few directories and copying the files into the right place. These instructions assume a default installation of Visual Studio 2005 and also that you have not redirected VS to an alternate bootstrapper package directory.
&lt;/p&gt;&lt;p&gt;&lt;span style="text-decoration:underline"&gt;Creating the directory structure
&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The default directory for bootstrapper packages is at C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages. Do the following:
&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;li&gt;Create a parent directory for the package named &lt;strong&gt;SqlExpressSP2&lt;/strong&gt;.
&lt;/li&gt;&lt;li&gt;&lt;div&gt;Under SqlExpressSP2, create the localized resource directory named &lt;strong&gt;EN&lt;/strong&gt;.
&lt;/div&gt;&lt;p&gt;&lt;span style="text-decoration:underline"&gt;Files in the SqlExpressSP2 directory
&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;Copy the contents of the product manifest that I've modified for SP2 (&lt;a href="http://blogs.msdn.com/sqlexpress/pages/sql-express-2005-sp2-vs-bootstrapper-manifest-product-xml.aspx"&gt;located here&lt;/a&gt;) and create a file in this directory named &lt;strong&gt;product.xml&lt;/strong&gt;.
&lt;/li&gt;&lt;li&gt;&lt;div&gt;Copy the file named SqlExpressChk.exe from the SQL Express 2005 RTM bootstrapper package (located at C:\Program Files (x86)\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\SqlExpress) into your SP2 version.
&lt;/div&gt;&lt;p&gt;&lt;span style="text-decoration:underline"&gt;Localized files in SqlExpressSP2\EN
&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;Download (or copy if you've got it already) the &lt;a href="http://go.microsoft.com/fwlink/?LinkID=83136&amp;amp;clcid=0x409"&gt;installer package&lt;/a&gt; for SQL Express SP2 from the Microsoft Download Center. (Note: This particular flavor of the manifest is specific for the 32-bit only install of SQL Express, which is named SQLEXPR32.EXE.)
&lt;/li&gt;&lt;li&gt;Copy the EULA from the SQL Express install location and save it to the name&lt;strong&gt; license.txt&lt;/strong&gt; in the EN directory. By default it is at C:\Program Files (x86)\Microsoft SQL Server\90\EULA and is named License_EXPR_ENU.txt.
&lt;/li&gt;&lt;li&gt;&lt;div&gt;Copy the contents of the manifest I've modified for SP2 (&lt;a href="http://blogs.msdn.com/sqlexpress/pages/sql-express-2005-sp2-vs-bootstrapper-manifest-package-xml.aspx"&gt;located here&lt;/a&gt;) and create a file in this directory named &lt;strong&gt;package.xml&lt;/strong&gt;.
&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Test your spankin' new bootstrapper package
&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;That's really all there is to do. You should now be able to launch Visual Studio 2005 and see SQL Server 2005 Express Edition SP2 listed in the prerequisites dialog. 
&lt;/p&gt;&lt;p&gt;&lt;strong&gt;There's always a catch
&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;There are a few known limitations with the package that is created using this method, here are the gotchas:
&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;ul&gt;&lt;li&gt;This set of manifests does not handle upgrades, only fresh installs.
&lt;/li&gt;&lt;li&gt;SqlExpressChk.exe is limited to only the default instance name, SQLEXPRESS. It won't detect other named instances.
&lt;/li&gt;&lt;li&gt;&lt;div&gt;This set of manifests is specific to the 32-bit only installer package. If you want to use the WoW enabled package (for installing on 64-bit platforms), you would need to make some changes to the manifest. (This would be a good point to go back and read those MSDN articles about the Generic Bootstrapper if you haven't already.)
&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Other bootstrapper solutions for SQL Express
&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;I know of at least one other description of a DIY SQL Express SP2 bootstrapper that was mentioned in a comment of the original post on the topic. Check out IGrocholski' blog &lt;a href="http://blogs.rbaconsulting.com/agrocholski/PermaLink,guid,d5b577b9-120f-43f7-b0f3-2adc80f393f5.aspx"&gt;post&lt;/a&gt; on this same topic. There are some difference between the approaches, particularly in discovery. You may also find other implementations by searching on the MSDN forums.
&lt;/p&gt;&lt;p&gt;I'm always happy to see community contribution, so feel free to share you own implementations with the rest of us by posting comments.
&lt;/p&gt;&lt;p&gt; 
 &lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;- Mike
&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4533076" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>Backup and Restore with User Instances</title><link>http://blogs.msdn.com/sqlexpress/archive/2007/03/20/backup-and-restore-with-user-instances.aspx</link><pubDate>Tue, 20 Mar 2007 23:14:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1921192</guid><dc:creator>sqlexpress</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/1921192.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=1921192</wfw:commentRss><description>&lt;P&gt;Backup and Restore is an important part of any application, but when you're writing an application for an end-user, it becomes even more important that you do a good job of handling Backup and Restore in your code since you end-user will likely not know much about being a Database Administrator. Add to that the fact that we don't include SQL Agent or the Maintenance Plan wizard in SQL Express, and you have the perfect reason to roll your own solution for Backup and Restore. &lt;/P&gt;
&lt;P&gt;SQL Management Objects (SMO) offers two classes with the likely name of &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.backup.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.backup.aspx"&gt;Backup&lt;/A&gt; and &lt;A href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.restore.aspx"&gt;Restore&lt;/A&gt; that can help you handle this in your application. These objects are documented in Books Online and you can even find a sample of their usage &lt;A href="http://msdn2.microsoft.com/en-us/library/ms162166.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms162166.aspx"&gt;here&lt;/A&gt;. One thing you won't find in the BOL example is information about how user instances impact the usage of these classes. Luckily, you have this blog and the help of your friends on the &lt;A href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=385&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=385&amp;amp;SiteID=1"&gt;SQL Express forum&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;Mfriedlander started a couple threads on the forum related to &lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1356666&amp;amp;SiteID=1" mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1356666&amp;amp;SiteID=1"&gt;backing up&lt;/A&gt; and &lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1370465&amp;amp;SiteID=1&amp;amp;mode=1" mce_href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1370465&amp;amp;SiteID=1&amp;amp;mode=1"&gt;restoring&lt;/A&gt; a database in a user instance. The trick with user instances is that the databases are typically auto named at runtime based on the path to the database file that is embedded into your project. VS and SQL Express work together using the |DataDirecotry| macro as part of the connection string to determine where the database is and how to dynamically name it. If you are using ClickOnce deployment, which is kind of the whole point of user instances, there are a number of things that will cause the location of the database to change, which means the database name will change over time. (This also has the result of not allowing you to give you database a static name using either Initial Catalog= or Database= in your connection string because the changing location of the database would cause a naming conflict, but that's a different post.) &lt;/P&gt;
&lt;P&gt;For the backup scenario, the workaround is fairly straight forward, you need to connect to the database using the VS created connection string and then return the name of the database from the connection. The restore version proved a bit more interesting. You can use the same trick of connecting to the database using the VS created connection string to get the database name, but that connection to the database causes a failure when you attempt to Restore because SMO cannot get an exclusive lock on the database. The solution turns out to be straight forward, simply change the database context of the connection you've opened with the ChangeDatabase method of the Connection object. I've created a C# sample that creates a full backup of an embedded database and then calls Restore on the same database. If you'd like to see the similar operation done in VB.NET, check out the forum posts that I've linked above. &lt;/P&gt;&lt;PRE&gt;using System;
using System.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;



namespace CreateRANU
{
    class Program
    {
        static void Main(string[] args)
        {
            BackupDatabase();
            RestoreBackup();
        }

        public static void BackupDatabase()
        {
            string sConnect = Properties.Settings.Default.BackupConnectionString;
            string dbName;

            using (SqlConnection cnn = new SqlConnection(sConnect))
            {
                cnn.Open();
                dbName = cnn.Database.ToString();

                ServerConnection sc = new ServerConnection(cnn);
                Server sv = new Server(sc);

                // Check that I'm connected to the user instance
                Console.WriteLine(sv.InstanceName.ToString());

                // Create backup device item for the backup
                BackupDeviceItem bdi = new BackupDeviceItem(@"C:\AppDataBackup\SampleBackup.bak", DeviceType.File);

                // Create the backup informaton
                Backup bk = new Backup();
                bk.Devices.Add(bdi); 
                bk.Action = BackupActionType.Database;
                bk.BackupSetDescription = "SQL Express is a great product!";
                bk.BackupSetName = "SampleBackupSet";
                bk.Database = dbName;
                bk.ExpirationDate = new DateTime(2007, 5, 1);
                bk.LogTruncation = BackupTruncateLogType.Truncate;

                // Run the backup
                bk.SqlBackup(sv);
                Console.WriteLine("Your backup is complete.");
            }
        }

        public static void RestoreBackup()
        { 
            string sConnect = Properties.Settings.Default.BackupConnectionString;
            string dbName;

            using (SqlConnection cnn = new SqlConnection(sConnect))
            {
                cnn.Open();
                dbName = cnn.Database.ToString();
                cnn.ChangeDatabase("master");

		        ServerConnection sc = new ServerConnection(cnn);
                Server sv = new Server(sc);

                // Check that I'm connected to the user instance
                Console.WriteLine(sv.InstanceName.ToString());

                // Create backup device item for the backup
                BackupDeviceItem bdi = new BackupDeviceItem(@"C:\AppDataBackup\SampleBackup.bak", DeviceType.File);

                // Create the restore object
                Restore resDB = new Restore();
                resDB.Devices.Add(bdi);
                resDB.NoRecovery = false;
                resDB.ReplaceDatabase = true;
                resDB.Database = dbName;

                // Restore the database
                resDB.SqlRestore(sv);
                Console.WriteLine("Your database has been restored.");
              }        
        }
        
        public static void CreateDatabase()
        {
            using (SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Integrated Security=True;User Instance=True;Connection Timeout=60"))
            {
                cn.Open();
                SqlCommand cmd = new SqlCommand("CREATE DATABASE forumTest1", cn);
                cmd.ExecuteNonQuery();

                SqlConnection cn2 = new SqlConnection(@"Data Source=.\SQLEXPRESS;Integrated Security=True;AttachDbFilename=|DataDirectory|\forumTest1.mdf;User Instance=True;Connection Timeout=60");
                cn2.Open();

            }        
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;Final Note: &lt;/P&gt;
&lt;P&gt;This example performs a full backup and restore of the database. If you're doing a full backup because your original database is totally lost the logic to retrieve the database name is going to fail because you won't be able to connect to the database (which has been lost or corrupted) to get the name. It's an interesting logic question as to figure out how to determine the right way to restore a database for a user instance when you can't connect to the original to get the right auto name from the project. I have a few ideas, but I'm interested in how others might do this. &lt;/P&gt;
&lt;P&gt;- Mike &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1921192" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>Source code for Embedding Webcast (Finally)</title><link>http://blogs.msdn.com/sqlexpress/archive/2006/08/21/source-code-for-embedding-webcast-finally.aspx</link><pubDate>Mon, 21 Aug 2006 23:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:711284</guid><dc:creator>sqlexpress</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/711284.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=711284</wfw:commentRss><description>&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;U&gt;Updated&amp;nbsp;Sample Available!&lt;/U&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&amp;nbsp;Steve Lasker (of SQL Server Compact fame) and I spent some time reworking this deployment sample for a presentation that Steve did at TechEd Barcelona at the end of 2007. You can find Steve's post including links to all his presentations &lt;A class="" href="http://blogs.msdn.com/stevelasker/archive/2007/11/07/presentations-demos-from-tech-ed-barcelona-07.aspx" mce_href="http://blogs.msdn.com/stevelasker/archive/2007/11/07/presentations-demos-from-tech-ed-barcelona-07.aspx"&gt;here&lt;/A&gt;. Of particular interest to this group is the updated &lt;A class="" href="http://steve.lasker.members.winisp.net/Demos/TechEdEMEA07/Express/ExpressScriptDeploy.zip" mce_href="http://steve.lasker.members.winisp.net/Demos/TechEdEMEA07/Express/ExpressScriptDeploy.zip"&gt;Deploying Database with Scripts&lt;/A&gt; sample code. The core principles of the sample have not changed from what is described below with a few changes:&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;Database deployment is 100% script based.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;Better organization of database scripts into a custom Resource&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;Cleaned up the the code to handle setting the data directory to use the right API to verify a ClickOnce deployed app (It's nice to have a VS expert helping out!)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;This sample is still based on a user instance connection string, but that is not required. This example could be tailored to create the database on the parent instance as well by just changing the connection string that is passed to the VerifyDatabase method.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;U&gt;Original sample code&lt;/U&gt; (for reference if you want it)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;At long last, I've posted the &lt;A href="http://blogs.msdn.com/sqlexpress/articles/711147.aspx" mce_href="http://blogs.msdn.com/sqlexpress/articles/711147.aspx"&gt;code&lt;/A&gt; for the &lt;A href="http://blogs.msdn.com/sqlexpress/archive/2006/05/11/595697.aspx" mce_href="http://blogs.msdn.com/sqlexpress/archive/2006/05/11/595697.aspx"&gt;embedding web cast&lt;/A&gt;. I've made a few changes to the code from what I showed in the webcast, here are some details about implementation and alternatives you can consider when thinking about this. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Alternative Databases &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;When I first put this webcast together, SQL Express was the primary database for creating end-user, data bound application in Visual Studio 2005. Since then, &lt;A href="http://www.microsoft.com/sql/ctp_sqlserver2005everywhereedition.mspx" mce_href="http://www.microsoft.com/sql/ctp_sqlserver2005everywhereedition.mspx"&gt;SQL Server 2005 Everywhere Edition&lt;/A&gt; has become available in CTP. For single user, local data scenarios, you should give SQL Everywhere Edition a serious look. You can check out more details about this product in &lt;A href="http://blogs.msdn.com/stevelasker/" mce_href="http://blogs.msdn.com/stevelasker/"&gt;Steve Lasker's blog&lt;/A&gt; and in the &lt;A href="http://blogs.msdn.com/SQLServerEverywhere/" mce_href="http://blogs.msdn.com/SQLServerEverywhere/"&gt;SQL Everywhere Edition team blog&lt;/A&gt;. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Implementation Details &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;There are a couple of things worth mentioning about this code: &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;STRONG&gt;User Instances&lt;/STRONG&gt;: I've chosen to do this sample with &lt;A href="http://msdn.microsoft.com/sql/express/default.aspx?pull=/library/en-us/dnsse/html/sqlexpuserinst.asp" mce_href="http://msdn.microsoft.com/sql/express/default.aspx?pull=/library/en-us/dnsse/html/sqlexpuserinst.asp"&gt;User Instances&lt;/A&gt; in order to showcase the ability to do all this in a non-admin framework, which is the point of ClickOnce. This is not a requirement and the code can be easily changed to use the normal instance of SQL Express if you'd rather go that way. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;STRONG&gt;Database Versioning&lt;/STRONG&gt;: I'm synching the database version using an Application Property (dbVersion) and a field in the AppInfo table in the database. I really wanted to use a built in property of the application to do this so it would happen automatically, but at the end of the day, there was no good way to do this, so it's one more property to remember to set. You can store the property in the database any way you like, just remember to update the property when you run a database update. The source code show the update script that I put into the application to install database version 1.0.0.1, which you'll notice updates the Version field in the AppInfo table. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;STRONG&gt;|DataDirectory| macro&lt;/STRONG&gt;: SQL Server 2005 and VS 2005 introduce the functionality to attach a database from a dynamic location using the |DataDirectory| macro. This is tied into ClickOnce deployment, so it can handle debuging an application and deploying an application. I wanted to have a bit more flexibility to also deploy by manually XCopy'ing the application to an arbitrary location and to allow the developer to specify a common directory for database installation. This is handled in SetDataPath(), which makes use of the DataDirectory property to change the directory path returned by the |DataDirectory| macro in the non-standard scenarios. Setting a customer directory is handled using the CustomDataDirectory property of the application. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;&lt;SPAN style="TEXT-DECORATION: underline"&gt;Calling the Class &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;This whole thing is implemented in a single class, calling it is pretty standard, instantiate the class and then call the single, Public method, VerifyDatabase(): &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;CheckDbVersion getDB = new CheckDbVersion(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;if (getDB.VerifyDatabase()) &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;{ &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;PopulateGrid(); &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;} &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;In this case, the PopulateGrid() method was a simple method that creates and fills a DataSet based on the sample database and uses the data to fill a DataGrid. It's straight forward code that you can find on MSDE and numerous other sources, so I'll not go into the details. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P style="MARGIN-LEFT: 7pt"&gt;&lt;SPAN style="FONT-SIZE: 12pt; FONT-FAMILY: Times New Roman"&gt;Go forth and embed those databases. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Mike &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=711284" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>FAQ: Detecting SQL Server 2005 using WMI</title><link>http://blogs.msdn.com/sqlexpress/archive/2006/07/29/faq-detecting-sql-server-2005-using-wmi.aspx</link><pubDate>Sat, 29 Jul 2006 10:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:682254</guid><dc:creator>sqlexpress</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/682254.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=682254</wfw:commentRss><description>&lt;P&gt;I've gotten a number of e-mails asking how to detect if SQL Express is installed on a computer. I'm finally getting around to putting this in the Blog so I don't have to keep typing the answer. We've made discovery much easier in SQL Server 2005 with the addition of the SQL Server 2005 WMI Provider. This method will work for all editions of SQL Server 2005, but the example is tailored to SQL Express. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why can't I just use the registry? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do a little research on this topic and you'll find a number of examples on how to use the registry to detect SQL Server. &lt;SPAN style="COLOR: #3366ff"&gt;Don't do it this way!&lt;/SPAN&gt; &lt;/P&gt;
&lt;P&gt;The problem with using the registry to detect SQL Server is that Microsoft doesn't make any promises that we won't change the registry without warning. (It's our registry, we can change it.) We changed the registry between SQL 2000 and SQL 2005 and it's a good bet well do the same between 2005 and what ever comes next. Enter the SQL WMI Provider, this provider abstracts the registry and allows you to discover information about SQL Server 2005. We will be maintaining the SQL WMI provider in future versions so that your detection code will continue to work on later versions. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Do I detect a catch? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Yes, you do. The SQL WMI Provider doesn't work for SQL Server versions prior to 2005. If you need to detect earlier versions, say 2000, you're pretty much back to your old registry tricks. &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;What else can the SQL WMI Provider do? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;What, you want more? Fine. The SQL WMI Provider actually covers a bunch of different functionality beyond detection and is broken into two separate providers: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms180560.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms180560.aspx"&gt;WMI Provider for Server Events&lt;/A&gt; - With this provider you can monitor events for a given instance of SQL Server. &lt;/P&gt;
&lt;P&gt;&lt;A href="http://msdn2.microsoft.com/en-us/library/ms180499.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms180499.aspx"&gt;WMI Provider of Configuration Management&lt;/A&gt; - With this provider you can detect and manage a given instance of SQL Server. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 9px"&gt;&lt;EM&gt;(If the links don't work for some reason, say MSDN completely restructures its content, just search for the topics in Books Online.) &lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why not use SMO?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;(Added in response to Jens'&amp;nbsp;comment.)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many observent readers (OK, it was just Jens) pointed out that SMO contains the ManagementServer namespace which offers similar functionality. I chose not to use SMO for a couple reasons:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;WMI does not require managed code or the .NET Framework. Yes, this is a C# sample, but the same WQL would work from VBScript on a computer without the framework installed. Sometimes it's important not to have a dependency on managed code.&lt;/LI&gt;
&lt;LI&gt;The SQL WMI Provider calls seem to handle being run on computers without SQL Server 2005 installed where SMO did not in my hands. I just had problems getting SMO based code to fail correct when SQL wasn't installed. I'm no SMO genious, so it's likely this was pilot error.&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;WMI is the detection mechanism recommend by our Servicing and Lifecycle Platform team and it does not have as many prerequisite as SMO. If you can count on the correct prerequisites being on the computer where you're wanting to detect SQL Express, feel free to check out the&amp;nbsp;SMO ManagementServer namespace. If you want to use the recommended method, stick with WMI.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Hey Explanation Boy, how about a sample? &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Ok already, I'll get to the sample. It’s in C# if you didn’t notice. &lt;/P&gt;&lt;PRE&gt;using System;
using System.Management;

namespace WMISample
{
    // The WMI query for this class was created using the WMI Code Creator tool
    // that is available from
    // http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e&amp;amp;DisplayLang=en
    public class MyWMIQuery
    {
        public static void Main()
        {
            bool foo = isExpressInstalled();
            if (foo)
            {
                Console.WriteLine("You have SQL Express SP1. Sweet!!");
            }
            else
            {
                Console.WriteLine("No instances named SQLEXPRESS exists on this computer.");
            }
            Console.WriteLine("Hit Enter to continue.");
            Console.Read();
        }

        public static bool isExpressInstalled()
        {
            const string edition = "Express Edition";
            const string instance = "MSSQL$SQLEXPRESS";
            const int spLevel = 1;

            bool fCheckEdition = false;
            bool fCheckSpLevel = false;

            try
            {
                // Run a WQL query to return information about SKUNAME and SPLEVEL about installed instances
                // of the SQL Engine.
                ManagementObjectSearcher getSqlExpress =
                    new ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ComputerManagement",
                    "select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" 
                    + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')");

                // If nothing is returned, SQL Express isn't installed.
                if (getSqlExpress.Get().Count==0)
                {
                    return false;
                }
                
                // If something is returned, verify it is the correct edition and SP level.
                foreach (ManagementObject sqlEngine in getSqlExpress.Get())
                {
                    if (sqlEngine["ServiceName"].ToString().Equals(instance))
                    {
                        switch (sqlEngine["PropertyName"].ToString())
                        {
                            case "SKUNAME":
                                // Check if this is Express Edition or Express Edition with Advanced Services
                                fCheckEdition = sqlEngine["PropertyStrValue"].ToString().Contains(edition);
                                break;

                            case "SPLEVEL":
                                // Check if the instance matches the specified level
                                fCheckSpLevel = int.Parse(sqlEngine["PropertyNumValue"].ToString()) &amp;gt;= spLevel;
                                //fCheckSpLevel = sqlEngine["PropertyNumValue"].ToString().Contains(spLevel);
                                break;
                        }
                    }
                }

                if (fCheckEdition &amp;amp; fCheckSpLevel)
                {
                    
                    return true;
                }
                return false;
            }
            catch (ManagementException e)
            {
                Console.WriteLine("Error: " + e.ErrorCode + ", " + e.Message);
                return false;
            }
        }
    }
}
&lt;/PRE&gt;
&lt;P&gt;isExpressInstalled() is the worker bee here. This method runs a WQL query that specifically looks for instances of the SQL Server Engine (SQLServiceType = 1) where the Instance Name is SQLEXPRESS (ServiceName = MSSQL$SQLEXPRESS). In the sample, I happen to pass the Instance Name as a variable &lt;EM&gt;instance&lt;/EM&gt;, but you can do it any way you want. I choose to look specifically for SQLEXPRESS for a couple reasons: It's the default Instance Name, Visual Studio Express and ClickOnce deployment use this Instance Name, and we'd like to see more applications pointing to a single Instance Name, so the default makes sense. Once it's established that an instance named SQLEXPRESS exists, a further check is made to ensure that it is actually one of the SQL Express Editions and that it is running at the correct service pack level, in this case, SP1 &lt;/P&gt;
&lt;P&gt;That's pretty much it, a few checks to see what happened, and the function returns either True or False to the calling routine. You can call this from where ever you want and adjust the parameters as appropriate. One final note, check out the WMI Code Creator as mentioned in the code comment. This is the tool that will help you explore the SQL Server 2005 WMI Provider to find other ways to use it and other properties that you can query. &lt;/P&gt;
&lt;P&gt;Mike &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Addendum&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Barry Sumpter converted this code into VB.NET in a forum post and I thought I'd add it here so it's easier to find.&lt;/P&gt;&lt;PRE&gt;Imports System
Imports System.Management

Namespace WMISample

    Public Class MyWMIQuery

        Public Shared Sub Main()

            Dim foo As Boolean = isExpressInstalled()

            If foo Then

                Console.WriteLine("You have SQL Express SP1. Sweet!!")

            Else

                Console.WriteLine("No instances named SQLEXPRESS exists on this computer.")

            End If

            Console.WriteLine("Hit Enter to continue.")

            Console.Read()

        End Sub

        Public Shared Function isExpressInstalled() As Boolean

            Const edition As String = "Express Edition"

            Const instance As String = "MSSQL$SQLEXPRESS"

            Const spLevel As Integer = 1

            Dim fCheckEdition As Boolean = False

            Dim fCheckSpLevel As Boolean = False

            Try

                Dim getSqlExpress As ManagementObjectSearcher = New ManagementObjectSearcher("root\Microsoft\SqlServer\ComputerManagement", "select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')")

                If getSqlExpress.Get.Count = 0 Then

                    Return False

                End If

                For Each sqlEngine As ManagementObject In getSqlExpress.Get

                    If sqlEngine("ServiceName").ToString.Equals(instance) Then

                        Select Case sqlEngine("PropertyName").ToString

                            Case "SKUNAME"

                                fCheckEdition = sqlEngine("PropertyStrValue").ToString.Contains(edition)

                            Case "SPLEVEL"

                                fCheckSpLevel = Integer.Parse(sqlEngine("PropertyNumValue").ToString) &amp;gt;= spLevel

                        End Select

                    End If

                Next

                If fCheckEdition And fCheckSpLevel Then

                    Return True

                End If

                Return False

            Catch e As ManagementException

                Console.WriteLine("Error: " + e.ErrorCode + ", " + e.Message)

                Return False

            End Try

        End Function

    End Class

End Namespace&lt;/PRE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=682254" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/FAQ/default.aspx">FAQ</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>New Starter Kit and Sample Applications</title><link>http://blogs.msdn.com/sqlexpress/archive/2006/06/12/628444.aspx</link><pubDate>Mon, 12 Jun 2006 20:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:628444</guid><dc:creator>sqlexpress</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/628444.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=628444</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=2&gt;We've release a number of samples that will help you explore the functionality of SQL Express (and Visual Studio too). This is just the first batch, so watch this space for some additional samples to be released in the near future. See the details of each sample below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana size=2&gt;Mike Wachal&lt;BR&gt;SQL Express team&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=h2&gt;&lt;B&gt;&lt;FONT face=Arial color=#eb6c29&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Collection Manager Starter Kit&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoNormalTable style="WIDTH: 100%" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; WIDTH: 100%; PADDING-TOP: 1.5pt" vAlign=top width="100%"&gt;
&lt;P class=h3a&gt;&lt;B&gt;&lt;FONT face=Arial color=black size=3&gt;&lt;SPAN style="FONT-SIZE: 11.5pt; COLOR: black"&gt;Overview&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;The Collection Manager is a rich client application that enables you to create and manage any type of collection. A sample database is included, and you can create any additional number of custom collection types to store unique characteristics about each collection.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=navy size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;A href="http://msdn.microsoft.com/vstudio/express/sql/starterkit/default.aspx#collection" target=_blank&gt;http://msdn.microsoft.com/vstudio/express/sql/starterkit/default.aspx#collection&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=h2&gt;&lt;B&gt;&lt;FONT face=Arial color=#eb6c29 size=3&gt;&lt;SPAN lang=FR style="FONT-SIZE: 12pt"&gt;Internet Explorer Favorites Sample Application&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoNormalTable style="WIDTH: 100%" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; WIDTH: 100%; PADDING-TOP: 1.5pt" vAlign=top width="100%"&gt;
&lt;P class=h3a&gt;&lt;B&gt;&lt;FONT face=Arial color=black size=3&gt;&lt;SPAN style="FONT-SIZE: 11.5pt; COLOR: black"&gt;Overview&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Use this application to more effectively manage your Internet Explorer Favorites and better understand your browser history. The Internet Explorer Favorites is a web application for keeping track of your Internet Explorer Favorites and reporting on your browser history. This sample application shows you how to incorporate SQL Server Reporting Services to provide rich reporting on data in SQL Server 2005.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=navy size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fmsdn.microsoft.com%2fvstudio%2fexpress%2fsql%2fsamples%2fdefault.aspx%23ie" target=_blank&gt;http://msdn.microsoft.com/vstudio/express/sql/samples/default.aspx#ie&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=h2&gt;&lt;B&gt;&lt;FONT face=Arial color=#eb6c29 size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Reports for Web Sample Application&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoNormalTable style="WIDTH: 100%" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; WIDTH: 100%; PADDING-TOP: 1.5pt" vAlign=top width="100%"&gt;
&lt;P class=h3a&gt;&lt;B&gt;&lt;FONT face=Arial color=black size=3&gt;&lt;SPAN style="FONT-SIZE: 11.5pt; COLOR: black"&gt;Overview&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;This sample application provides a web-based user interface to view rich reports based on different business queries.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;EM&gt;&lt;I&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Note: This sample application requires &lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fmsdn.microsoft.com%2fvstudio%2fexpress%2fvwd%2fdownload%2fdefault.aspx" target=_blank&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman'"&gt;Visual Web Developer&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt;, &lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fmsdn.microsoft.com%2fvstudio%2fexpress%2fvb%2fdownload%2fdefault.aspx" target=_blank&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman'"&gt;Visual Basic Express&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt; and the &lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fdownload.microsoft.com%2fdownload%2f4%2f4%2fD%2f44DBDE61-B385-4FC2-A67D-48053B8F9FAD%2fSQLServer2005_ReportAddin.msi" target=_blank&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman'"&gt;Report Viewer Add-in for Microsoft Visual Web Developer&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/EM&gt;&lt;FONT face=Verdana color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1182 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;View different business queries through a web interface.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1183 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;Understand how to embed reports into websites&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1184 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;Extend the application by modifying the included reports&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=navy size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;A href="http://msdn.microsoft.com/vstudio/express/sql/samples/default.aspx#web" target=_blank&gt;http://msdn.microsoft.com/vstudio/express/sql/samples/default.aspx#web&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=h2&gt;&lt;B&gt;&lt;FONT face=Arial color=#eb6c29 size=3&gt;&lt;SPAN style="FONT-SIZE: 12pt"&gt;Reports for Windows Sample Application&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;
&lt;TABLE class=MsoNormalTable style="WIDTH: 100%" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="PADDING-RIGHT: 1.5pt; PADDING-LEFT: 1.5pt; PADDING-BOTTOM: 1.5pt; WIDTH: 100%; PADDING-TOP: 1.5pt" vAlign=top width="100%"&gt;
&lt;P class=h3a&gt;&lt;B&gt;&lt;FONT face=Arial color=black size=3&gt;&lt;SPAN style="FONT-SIZE: 11.5pt; COLOR: black"&gt;Overview&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;This sample application provides a rich client interface to view rich reports based on different business queries.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=p1&gt;&lt;EM&gt;&lt;I&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;Note: This sample application requires &lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fmsdn.microsoft.com%2fvstudio%2fexpress%2fvb%2fdownload%2fdefault.aspx" target=_blank&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman'"&gt;Visual Basic Express&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt; and the &lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fwww.microsoft.com%2fdownloads%2fdetails.aspx%3fFamilyID%3d8a166cac-758d-45c8-b637-dd7726e61367" target=_blank&gt;&lt;FONT face="Times New Roman"&gt;&lt;SPAN style="FONT-FAMILY: 'Times New Roman'"&gt;Microsoft Reportviewer Redistributable&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/I&gt;&lt;/EM&gt;&lt;FONT face=Verdana color=black&gt;&lt;SPAN style="COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1188 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;View different business queries through a rich client interface&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1189 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;Understand how to embed reports into rich client applications&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P class=bulletlist&gt;&lt;FONT face=Verdana color=black size=1&gt;&lt;SPAN style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana"&gt;&lt;IMG class=bullet_padding id=_x0000_i1190 height=6 src="https://exchange.microsoft.com/OWA/attachment.ashx?id=RgAAAAAyjadL6b3uSqqiiaOCUfZiBwDo0tJpsFPgTKWR5vHn8SOKAAABDE2sAAAxECAI%2fOtrSYz6Ll7fsSNyAABc3GNBAAAI&amp;amp;attcnt=1&amp;amp;attid0=EADFLXoGzdUIQK4itMaozLc%2b" width=6 border=0&gt;Extend the application by modifying the included reports &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P class=MsoNormal&gt;&lt;FONT face=Arial color=navy size=2&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"&gt;&lt;A href="https://exchange.microsoft.com/OWA/redir.aspx?URL=http%3a%2f%2fmsdn.microsoft.com%2fvstudio%2fexpress%2fsql%2fsamples%2fdefault.aspx%23windows" target=_blank&gt;http://msdn.microsoft.com/vstudio/express/sql/samples/default.aspx#windows&lt;/A&gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=628444" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>Report Packs and SQL Server Express</title><link>http://blogs.msdn.com/sqlexpress/archive/2006/04/11/573569.aspx</link><pubDate>Tue, 11 Apr 2006 21:15:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:573569</guid><dc:creator>sqlexpress</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/573569.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=573569</wfw:commentRss><description>&lt;FONT color=#000080&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Arial size=2&gt;The SQL Server team recently released &lt;/FONT&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?familyid=D81722CE-408C-4FB6-A429-2A7ECD62F674&amp;amp;displaylang=en"&gt;&lt;FONT face=Arial size=2&gt;eight new SQL Server 2005 Report Packs for download&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face=Arial size=2&gt;.&amp;nbsp; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;Use the Report Packs as way to get up and running on Reporting Services in SQL Server 2005 Express. The Report Packs include sample reports and databases for views into commonly used application data such as IIS logs, and SharePoint Portal Server stats. You can also share your own samples by uploading the bits to &lt;/FONT&gt;&lt;A href="http://www.gotdotnet.com/codegallery/codegallery.aspx?id=7727c619-25c0-4664-87ef-4f818c4a57b3"&gt;&lt;FONT size=2&gt;http://www.gotdotnet.com/codegallery/codegallery.aspx?id=7727c619-25c0-4664-87ef-4f818c4a57b3&lt;/FONT&gt;&lt;/A&gt;&lt;FONT size=2&gt; and contributing to the message boards.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;FONT color=#000000&gt;
&lt;P&gt;&lt;FONT color=#000000&gt;&lt;FONT face=Arial&gt;&lt;FONT size=2&gt;To run these reports on SQL Server Express, you need to attach the included databases (.mdf files) included with the report packs to SQL Server Express (&lt;EM&gt;hint&lt;/EM&gt;: you can use SQL Server Management Studio Express, where you can also easily browse the database schemas and get a better understanding of how the report packs work).&amp;nbsp; &amp;nbsp;Also, you will likely &lt;FONT color=#000000&gt;need to make two changes in Business Intelligence Development Studio (BIDS). First, change your project’s report server URL to &lt;A href="http://localhost/reportserver$SQLExpress "&gt;http://localhost/reportserver$SQLExpress &lt;/A&gt;&lt;FONT color=#000080&gt;&lt;FONT color=#000000&gt;(go to Project-&amp;gt; &amp;lt;Project name&amp;gt; Properties). You will also need to change the connection string for your data source to ".\SQLEXPRESS". Once you’ve done that, you should be able to preview your reports in BIDS and then deploy them to your report server.&lt;/FONT&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=573569" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Product+Info/default.aspx">Product Info</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Headlines/default.aspx">Headlines</category></item><item><title>Various Downloads of Samples and Documentation for SQL Express</title><link>http://blogs.msdn.com/sqlexpress/archive/2004/07/22/190901.aspx</link><pubDate>Thu, 22 Jul 2004 09:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:190901</guid><dc:creator>sqlexpress</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/190901.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=190901</wfw:commentRss><description>&lt;P&gt;MSDN has a downloads page specific to express:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2adbc1a8-ae5c-497d-b584-eab6719300cd&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=2adbc1a8-ae5c-497d-b584-eab6719300cd&amp;amp;displaylang=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Euan Garden&lt;/P&gt;
&lt;P&gt;Product Unit Manager&lt;/P&gt;
&lt;P&gt;SQL Server Tools&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=190901" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/General/default.aspx">General</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>Sample: VB.Net Express and SQL Express Music Manager on MSDN</title><link>http://blogs.msdn.com/sqlexpress/archive/2004/07/12/181222.aspx</link><pubDate>Tue, 13 Jul 2004 03:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:181222</guid><dc:creator>sqlexpress</dc:creator><slash:comments>13</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/181222.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=181222</wfw:commentRss><description>&lt;P&gt;Brian has a great &lt;A href="http://msdn.microsoft.com/sql/default.aspx?pull=/library/en-us/dnsse/html/sse_ManMusicColl.asp"&gt;sample&lt;/A&gt;&amp;nbsp;on MSDN that shows off new features in the express SKUs. It really looks cool and pretty simple in terms of code. Please give us feedback as we have more samples planned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Euan Garden&lt;/P&gt;
&lt;P&gt;Product Unit Manager&lt;/P&gt;
&lt;P&gt;SQL Server Tools&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=181222" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category></item><item><title>FAQ: How do I write objects in Managed code, the beta 1 samples/docs on the web don't work with SQL Express?</title><link>http://blogs.msdn.com/sqlexpress/archive/2004/07/04/172955.aspx</link><pubDate>Mon, 05 Jul 2004 04:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:172955</guid><dc:creator>sqlexpress</dc:creator><slash:comments>10</slash:comments><comments>http://blogs.msdn.com/sqlexpress/comments/172955.aspx</comments><wfw:commentRss>http://blogs.msdn.com/sqlexpress/commentrss.aspx?PostID=172955</wfw:commentRss><description>&lt;P&gt;The syntax for much of SQLCLR was changed between B1 and the current builds to make it more consistent. Building SQLCLR objects in Visual Studio 2005 is really easy as we have new project types, but the Express SKUs of VS do not include this project type so the code has to be written by hand. The below is a sample from Ramachandran Venkatesh one of the PMs on the SQLCLR team in SQL Server.&lt;/P&gt;
&lt;P&gt;-Euan Garden&lt;/P&gt;
&lt;P&gt;Product Unit Manager&lt;/P&gt;
&lt;P&gt;SQL Server Tools&lt;/P&gt;
&lt;P&gt;***C# Sample***&lt;/P&gt;
&lt;P&gt;Here is a soup-to-nuts sample to build a hello world function in C#, illustrating the basic steps of creating a source file, compiling it, registering the assembly, creating a function over it, and then invoking the function.&lt;BR&gt;&lt;BR&gt;public class c&lt;BR&gt;{&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static string HelloWorld() { return "hello world"; }&lt;BR&gt;}&lt;BR&gt;save to hello.cs,&lt;BR&gt;&lt;BR&gt;csc /t:library hello.dll hello.cs&lt;BR&gt;&lt;BR&gt;***The following code needs to be executed in a query editor***&lt;/P&gt;
&lt;P&gt;create assembly hello from 'c:\hello.dll'&lt;BR&gt;go&lt;BR&gt;&lt;BR&gt;create function hello() returns nvarchar(129) as external name &lt;BR&gt;[hello].[c].[HelloWorld]&lt;BR&gt;go&lt;BR&gt;&lt;BR&gt;select dbo.hello()&lt;BR&gt;go&lt;BR&gt;&lt;BR&gt;Ofcourse this is just the tip of the iceberg, in terms of the functionality, but you get an idea of the basic sequence.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=172955" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Samples/default.aspx">Samples</category><category domain="http://blogs.msdn.com/sqlexpress/archive/tags/Archive/default.aspx">Archive</category></item></channel></rss>