Accessing Sample Database Data (Part 1)

It’s always hard to figure out the best way to provide access to sample data in a book. No matter how you do it, someone is going to find the amount of data limited or unrealistic, too hard to understand, too hard to access, or too hard to install.

One of the most common ways to provide sample data is to use a predefined database, such as Northwind or the newer AdventureWorks, that the reader can download and install. However, there are several problems with using these databases. For one thing, installing Northwind requires running a script that may not succeed (and then I get questions about why my script failed—unfortunately, it isn’t my script, it’s Microsoft’s script). Using AdventureWorks requires a copy of the SQL Server tools because you install the actual database and the tools don’t come with Visual Studio’s copy of SQL Server Express any longer, so now I also need to tell the reader how to install the required tools. In both cases, many readers find the process of working with these predefined databases too complicated. Once the databases are installed, many readers find the database design unrealistic and overly complicated (especially in the case of AdventureWorks, which really is complex). In addition, as more of my books move toward the open source realm, I can’t assume the reader will even have a copy of SQL Server. (If someone has a suggestion for a great open source alternative, please let me know.)

Another technique is to create a predefined database that I supply with the book’s downloadable code and ask the reader to install it as necessary. When working with a book that uses SQL Server, this means including the actual database file or creating a script to reproduce it. Again, the reader would need to install these files in some way—either by running the script or installing the database file using the SQL Server tools. When writing open source books, I’m leaning toward using XML databases because they’re text-based, simple to work with, and work on any platform. At least XML databases don’t require installation or scripts because they appear in the same folder as the application does. Because these databases specifically model the book environment, readers don’t complain about complexity or applicability, but some readers complain that they also don’t model their environment very well.

Of course, there is always the approach that I take in some books of having the reader build the database as part of the learning experience and then typing the data into it. The amount of data is small in most cases, so it’s not as if the reader is working for hours to input the information. However, this solution garners criticism because it’s too simplistic (doesn’t model the real world well enough) and readers feel that it’s more important to see working code, rather than work with the database. After all, database design is an entirely different specialty (some developers will be surprised when their employer asks them to create databases as part of their job). There is also that constant problem with the availability of tools—many of which are solved with Server Explorer when working with Visual Studio, but again, many of my projects are moving more toward open source.

In an effort to address the complaint about not spending enough time in the IDE and in creating code, there is always the approach of having the reader build an application that creates the database and fills it with data. The complaint this time is that most readers will never build such an application (I disagree because such applications are used all the time for storing settings and other application-specific information). What the reader really wants to see is the code that manipulates the database data and lots of it (sometimes without the level of explanation that less experienced readers require to actually understand the example). It’s important that I address all reader needs with the examples I create, so you’ll continue to see examples that create the database and fill it with data. The examples will always include full explanations so that no one is left behind. However, I am providing more references to online examples that emphasize code, lots of it, over any sort of explanation.

The point is that there are a number of ways in which an author can attempt to satisfy reader needs when writing a book that contains database management techniques. To make the book useful, the reader must have a database of some sort to work with. Whether the database is XML-based, SQL Server-based, or some new type of data source isn’t the problem for the most part—it’s creating a database that works well with the book’s material, models a real world environment to some degree, and is still easy enough to understand that the reader doesn’t become lost in detail. In order to accomplish these goals, more of my books now employ multiple database scenarios so that each reader type has enough data of the right type to get the maximum possible benefit from the book examples.

Of course, undertaking such a gargantuan task isn’t easy. Every one of you seems to have an entirely different set of needs. The next post in this series is going to attempt to demystify the process of getting the databases installed when working with SQL Server and Visual Studio. I also include instructions in my books, but this additional information is based on feedback from less experienced readers who are having trouble gaining access to the databases. What I’d like is to hear your questions so that I can address them in future posts. If you’ve had a problem getting one of my database examples to work because you can’t access the data, please let me know at You can find the next post in this series at Accessing Sample Database Data (Part 2).


Starting SQL Server Browser

A number of my books contain database examples in them—most of which rely on SQL Server. One of the issues I’ve encountered over the years is that a reader will write in to say that the example doesn’t work as written. In most cases, the procedure and the example source code is just fine. In addition, there is nothing wrong with the user’s system, the Visual Studio installation, or the version of SQL Server used. The problem lies in the fact that the SQL Server Browser service isn’t started. Visual Studio relies heavily on this particular service and it isn’t started by default, in most cases, when you install SQL Server or SQL Server Express.

Unfortunately, the error message you receive will say nothing at all about SQL Server Browser. In fact, the message will complain about something completely unrelated and it may not even point to the database as the problem. This particular error has caused me (and many others) a lot of lost time. In fact, it’s such a nuisance that I immediately check to ensure the service is actually running before I look for other sources of problems (unless there is another obvious problem source). When you encounter an odd problem, especially an odd problem with source code that has worked in the past, and the application relies on a database, consider checking the SQL Server Browser service to ensure its running.

There are commonly two places in which you can look for the SQL Server Browser service. Because the SQL Server tools don’t install with the copy of SQL Server Express that comes with Visual Studio, I’ll discuss the place that everyone can look first, which is the Services console found in the Administrative Tools folder of the Control Panel. Simply open the console up, locate the SQL Server Browser entry, and ensure that it’s running as shown here.


Notice that the service is set to start automatically each time the machine is booted. Using this setting usually ensures that the service will be available when needed. However, don’t assume that this setting means the service is always going to be available. If the service encounters a problem during the boot process, there is every chance that it won’t be available when you need it. Always verify that the service is indeed running when you encounter problems.

You can start a service by clicking the Start link on the left side of the right pane. The figure shows the Stop, Pause, and Restart options because the services is already started, but the Start option will appear when the service is stopped. If the service isn’t set up to start automatically, right click the service’s entry in the list and choose Properties from the context menu. Set the Startup Type field value to Automatic and click OK to configure the service to start automatically.

The second place you can look for this setting (when you have the SQL Server tools installed) is the SQL Server Configuration Manager. You’ll find the SQL Server Browser entry in the SQL Server Services folder as shown here.


Again, make sure the service is actually running and that you have it configured to start automatically. Otherwise, you’ll find that you spend a lot of time chasing ghost problems that don’t actually exist. Of course, I’m always here to help you with any book-related problems you might have. Feel free to contact me about any issues with my books at


Installing and Managing Third Party Products

Most of my books make recommendations about third party products that you can use to enhance your computing experience. Each of these products is tested during the writing process, but without any of the add-on applications that may come with the product. For example, if I test a Windows enhancement product, I don’t test the toolbar that comes with that product. So, it’s important to realize that the advice you obtain in the book doesn’t include those add-on features.

However, it’s important to take a step back at this point and discuss why the product includes an add-on in the first place. Just like you, the product vendor has bills to pay and must obtain money from somewhere to pay them. An important concept to remember when working with computers is that free doesn’t exist. Typically, product vendors who offer free products will do so by paying for them in one of these ways:

  • Advertisements: Advertising comes in many forms, not just banner ads. Marketing types constantly come up with new ways to advertise products and induce you to buy them. A developer can obtain payment from advertisements in several ways, such as referral fees.
  • Product Add-ons: A developer can provide the means to install other products with the product that you’re installing. The company who provides the additional product sponsors the free product that you’re using.
  • Marketing Agreements: The application collects information about you and your system when you install it and the developer sells this information to marketing companies.
  • Value-added Products: The free product that you’re using is just a sample of some other product that the developer provides. If you like the free product, the developer is hoping that you’ll eventually purchase the full-fledged product.
  • Government Grants: A developer creates a product after obtaining a grant from the government. You pay for the product through your taxes.
  • Sponsorship: A larger company supports a developer’s work to determine whether the idea is marketable or simply the seed of something the larger company can develop later. You pay for the product through higher prices when you buy something from the larger company.

There are other methods that developers use to get paid for their work, but the bottom line is that they get paid. Whenever you see free, your mind should say, “This product doesn’t cost money, but there is some other price.” You need to decide whether you’re willing to pay the price the developer is asking. In the case of a government grant, you’ve already paid the price.

When you install a free product, you must watch the installation routine carefully. In almost every case, you must opt out of installing add-on products that the free product supports. So, you have to read every screen carefully because these opt-out check boxes are usually small and hard to see. The developer really isn’t pulling a fast one—just trying to earn a living. Make sure you clear any check boxes you see for installing add-on products if you don’t want that product on your machine. The reason I don’t discuss these check boxes in my books is that they change constantly. Even if I were to tell you about the check boxes that appeared at the time I installed the free product, your experience is bound to be different.

Of course, you might accidentally install one of these add-ons, an add-on that you really didn’t want. In this case, you must locate the product in the list of products installed on your system, such as the Programs and Features applet of the Control Panel for Windows users. The product name won’t be straightforward, but a little research will help you find it. Simply uninstall the add-on product. However, it’s always better to avoid installing something you don’t want to begin with, rather than remove it later, because few applications uninstall cleanly (even those from larger vendors such as Microsoft).

Unfortunately, there isn’t much I can do to help you when you install an add-on product. I do have some experience with the third party product in my book, but I won’t know anything about the add-on product. You need to contact the developer of the third party product to ask for advice in removing it from your system. This may seem like I’m passing the buck, but the truth is that the add-on products change all the time and there simply isn’t any way I can keep up with them all. When in doubt, don’t install a product, rather than being sorry you installed it later. Let me know your thoughts on third party products at


Checking SQL Server Status

A number of my books rely on database access and one of the most common servers that I’ve used in the past is SQL Server. In order to access any server, the server must be running. It only makes sense that you can’t access something that isn’t listening. The problem is that SQL Server may not start automatically for a number of reasons on your system and that Visual Studio doesn’t always make it apparent that the server isn’t running. You may get a nebulous message when you try to make a connection that doesn’t tell you anything. (No, SQL Server doesn’t start automatically when you make a request for data.) With this in mind, a post of checking the status of SQL Server is important.

Normally, I would tell you to use the tools that come with SQL Server to check the status of the server. However, some versions of SQL Server Express Edition install without the standard tools now, such as SQL Server Management Studio. Without access to these tools, it may seem as if checking the server status is impossible. Fortunately, you have other options.

The best way to check the status of SQL Server on your system is to use the Services console found in the Administrative Tools folder of the Control Panel. The Services console is one of a number of Microsoft Management Console (MMC) snap-ins that Windows installs automatically for you. However, to use this console, you must have administrator rights on the target system. Without these rights, you truly are out of luck in checking the status of your SQL Server setup and will need to get an administrator to help you.

Open the Services console and you find a list of all of the services installed on your system. Scroll down the list and you should find one or more SQL Server entries like the ones shown here.


In order to work successfully with the examples in my book, you should have SQL Server set to start automatically. In addition, when you check the service, you should see Started in the Status column as shown in the screenshot. If you don’t see Started, then highlight the service as shown and click the Start link you see on the left side (not shown in this case because the service is already started).

To make the examples easier to work with, you should also ensure that the SQL Server Browser service is started. This service makes it possible for Visual Studio to find the SQL Server installation on your system. Without this service, you must correctly type the name of the SQL Server installation you want to use when creating a connection, which is both time consuming and error prone.

If you find that you encounter problems making database examples in my books work, please check the status of SQL Server to ensure the service is actually started. Contact me at if you experience any other connectivity problems. I may not be able to fix every problem you encounter, but I often have a good idea of what problems you might be seeing on your system and will do my best to help you.


.NET Framework Version Error When Installing Visual Studio 2012

I received a few messages from readers recently asking about an error message they receive when trying to install the release version of Visual Studio 2012 on their Windows 8 system (I imagine that the same error will occur when installing on Windows Server 2012, but no one has contacted me about it). The error says that Visual Studio 2012 can’t install because the version of the .NET Framework 4.5 is wrong.

Unfortunately, the error message isn’t very helpful. You can’t install a new version of the .NET Framework 4.5 over the top of the existing installation. In addition, you can’t uninstall the old version and then install the new version because Windows 8 requires the .NET Framework 4.5 for certain operating system elements. In short, there isn’t any apparent way to fix the problem.

The issue will go away at some point because it originates as a conflict between the Windows 8 version and the Visual Studio 2012 requirements. Every reader who has had this problem is using a non-released version of Windows 8 (normally the RC version). You can’t install the release version of Visual Studio 2012 on a non-release version of Windows 8. I’m assuming that the same error occurs if you try to install a release version of Visual Studio 2012 on a non-release version of Windows Server 2012, but I’d like to hear if anyone has tried this out at

What concerns me about this particular error is that it’s one time where Microsoft could have (and probably should have) come up with a substantially better error message or provided some sort of Knowledge Base article on the topic. As far as I know, there isn’t any such article and developers are currently having to rely on community support to fix this problem. It isn’t the first time Microsoft has left developers wondering. If you ever encounter this sort of problem, please let me know about it. If I can confirm the issue, I’ll put together a blog entry about it to get the word out to others in order to save them a bit of time.


Choosing the Right Express Edition Version

A lot of my readers rely on the Visual Studio Express Edition products to follow the examples in my book with good reason—the product is a free download. Books like Start Here! Learn Microsoft Visual C# 2010 Programming are actually designed from the ground up to use Visual Studio Express Edition. Even though I wrote Professional Windows 7 Development Guide with the purchased product in mind, most of the examples work just fine with the Express Edition as well. It makes sense to me that you’d want to try to learn as much as possible without making a huge commitment in software, so I welcome hearing about your Express Edition experiences.

The latest issue I’m encountering with readers is that Microsoft has changed how the Express Edition downloads work for Visual Studio 2012. There are now several versions of the Express Edition and you have to be sure you download the correct version to ensure that the IDE works with your operating system and my books. Make sure you download Express for Windows Desktop, not Express for Windows 8 (which doesn’t install on anything but Windows 8). The Express for Windows Desktop works with the following operating systems.


  • Windows 7 SP1 (x86 and x64)
  • Windows 8 (x86 and x64)
  • Windows Server 2008 R2 SP1 (x64)
  • Windows Server 2012 (x64)


This version of the Express Edition will let you create a number of application types. For example, you can create these sorts of applications:


  • Windows Presentation Foundation (WPF)
  • Windows Forms (WinForms)
  • Win32

Notice that there is no Metro support included with this version. None of my books currently support Metro either. However, if you decide you want to create a Metro application, then you need to download the Express for Windows 8 version and you must install it on a Windows 8 system to use it. Even though the downloads may look confusing, the differences between them are really straightforward.

Make sure you meet all of the requirements for install Visual Studio 2012 on your machine. The Express for Windows Desktop version has these requirements:


  • 1.6 GHz or faster processor
  • 1 GB of RAM (or 1.5 GB when running on a virtual machine)
  • 5 GB of available hard disk space
  • 100 MB of available hard disk space
  • 5400 RPM hard disk drive
  • DirectX 9-capable video card running at 1024 x 768 or higher display resolution

Don’t get the idea that my books require Visual Studio 2012. All of my existing books work just fine with the Visual Studio 2010 Express Edition. This version works on older versions of Windows and has smaller system requirements. Of course, Microsoft will remove this product from its site at some point, so if you want to use this older version, make sure you download it now.

Let me know if you encounter any additional difficulties using the Visual Studio 2012 Express for Windows Desktop with my books at In the meantime, happy coding!


Working with NuGet to Obtain the Entity Framework

My newest book project, Entity Framework Development Step-by-Step, discusses Entity Framework 5, the latest version of the Entity Framework that Microsoft has released. However, most of the discussions you read about online discuss obtaining Entity Framework 5 using NuGet, a new method that Microsoft is using to help you download and install products for Visual Studio. The only problem is that the process for making all this work isn’t very clear for Visual Studio 2010 developers (NuGet comes installed for Visual Studio 2012 developers).

I want everyone to be able to work with my book at some point, so I’m providing you with some instructions for getting Entity Framework 5 using NuGet. Along with Entity Framework 5, you’ll also be able to obtain a number of other interesting packages using NuGet, so this isn’t a product you’ll use once and then forget about. With this in mind, let’s get started installing the Entity Framework 5 and then you can use a similar process to install other NuGet packages. (These instructions may change with time, so please contact me at if you experience any difficulties.)

  1. Open your copy of Visual Studio 2010.
  2. Choose Tools | Extension Manager. You’ll see the Extension Manager window open.
  3. Verify that you haven’t already installed the NuGet Package Manager extension by selecting the All folder and reviewing its contents.
  4. Click the Online Gallery tab. You’ll see a Retrieving Information message for a few seconds as Visual Studio retrieves the required information. After Visual Studio finds all of the possible extensions, you see NuGet Package Manager displayed as shown here.
  5. Click Download. You see a Download and Install dialog box that shows a progress indicator. After a few moments, you’ll see a UAC dialog box asking permission to run the VSIXInstaller. Click Yes and you’ll see the Visual Studio Extension Installer dialog box.
  6. Read the licensing terms and click Install. After a moment, the installation completes and you see a success dialog box.
  7. Click Close. Visual Studio will display the Extension Manager window again. Notice the Restart Now button at the bottom of the window.
  8. Click Restart Now. Visual Studio restarts and the NuGet Package Manager is ready for use.
  9. Create the new project where you want to use the Entity Framework 5.0. NuGet will absolutely refuse to install the Entity Framework unless you have a solution open. This is because installing the Entity Framework creates a new file named packages.config that contains the information about the package.
  10. Choose Tools | Library Package Manager | Package Manager Console. You see a new Package Manager Console window open.
  11. At the PM> prompt, type Install-Package EntityFramework and press Enter. You see the NuGet Package Manager install Entity Framework 5.0 support for the solution you just created.


The Package Manager Console lets you interact with NuGet and the Entity Framework. To object help with NuGet, type get-help NuGet and press Enter. Likewise, to obtain help with the Entity Framework, type get-help EntityFramework and press Enter. I’ll be providing some additional posts like this one as time permits. In the meantime, please let me know your thoughts and concerns about the Entity Framework at

Entity Framework Programmer Beta Readers Needed

Next week I’ll begin work on my 91st book, “Entity Framework Development Step-by-Step.” This technology is really exciting. Microsoft keeps improving the Entity Framework support and Entity Framework 5 is no exception. Just in case you haven’t seen it, Microsoft recently released the Entity Framework 5 release candidate through NuGet. You can read about the updated technology on the ADO.NET blog.


The Entity Framework is an ADO.NET technology that maps a database and its underlying structures to objects that a developer can easily access within application code. Before the Entity Framework, a developer needed to write code that directly accessed to the database, which caused considerable problems every time the database received an update. The Entity Framework helps shield applications from underlying changes in a database. You can read about the Entity Framework in more detail in the Entity Framework Overview provided by Microsoft. Microsoft also provides a support center that offers some basic Entity Framework learning tools.

The Entity Framework is amazing technology because it greatly reduces the work you need to do and even automates many of the processes used to interact with databases. My book will make performing tasks even easier. As you go through the book, you’ll see how to perform many Entity Framework-related tasks using step-by-step procedures. There won’t be any guesswork on your part. As a beta reader, you’ll be able to provide me input on when these procedures work, and when I need to work on them some more to help prevent Errors in Writing.

You may have an Entity Framework book on your bookshelf already. However, if that book is on an older version of the Entity Framework, you really do need to know about the new features that the Entity Framework provides. In addition, my book will highlight these five essential topics:


  • Choosing the right workflow: The main reason this topic is important is that the Entity Framework actually supports several different workflows and they’re all useful in different ways and for different projects.

  • Using LINQ to interact with the Entity Framework: LINQ presents the fastest, most efficient, and least troublesome way to perform basic tasks with the Entity Framework. Of course, this book also discusses more complex methods, but making things simple is essential for the overburdened developer today.

  • Working with Table-Valued Functions: This is a new major feature in the Entity Framework 5 that developers have been requesting for years.

  • Complete application health checking: Because you likely work in an enterprise environment, simply discussing exception handling isn’t enough. You also need to know how to deal with other application health issues, such as what to do when an application has concurrency issues or how to address speed problems. An entire part of the book is devoted to the topic of application health because more organizations than ever are paying close attention to this topic now (as evidenced by the large number of books and articles being created on the topic of Application Performance Monitoring, or APM).

  • Entity customization: Yes, Entity Framework automation is quite good and gets better with every release, but as with any other form of automation, it has limits. Automation can only address those issues that the creator of the automation originally envisioned for it. Developers have a habit of coming up with situations that the automation can’t handle, so that’s why the last part of the book discusses this issue to some degree. I’m not going to delve into this topic so deeply that you feel overwhelmed, so my treatment of the topic is unique in that it gives you a useful set of skills without burdening you with topics so complex that the information becomes buried in jargon.

As I said, I’m really excited about this book and would love to have you read it as I write it. Your input is essential to me. Let me know if you’d like to be a beta reader for this book at