In Praise of Dual Monitors

A lot of people have claimed that the desktop system is dead—that people are only interested in using tablets and smartphones for computing. In fact, there is concern that the desktop might become a thing of the past. It’s true that my own efforts, such as HTML5 Programming with JavaScript for Dummies and CSS3 for Dummies, have started to focus on mobile development. However, I plan to continue using my desktop system when working because it’s a lot more practical and saves me considerable time. One such time saver is the use of dual monitors.

Yes, I know that some developers use more than just two monitors, but I find that two monitors work just fine. The first monitor is my work monitor—the monitor I use for actually typing code. The second monitor is my view monitor. When I run the application, the output appears on the second monitor so that I can see the result of changes I’ve made. Using two monitors lets me easily correlate the change in code to the changes in application design. Otherwise, I’d be wasting time switching between the application output and my IDE.

I also use two monitors when writing my books. The work monitor contains my word processor, while my view monitor contains the application I’m writing about. This is possibly one time when a third monitor could be helpful—one to hold the word processor, one to hold the IDE, and one to view the application output. However, in this case, a third monitor could actually slow things down because the time spent viewing the output of an example is small when compared to creating a production application.

The concept of separating work from the source of information used to perform the work isn’t new. People have used the idea for thousands of years, in fact. For example, when people employed typewriters to output printed text, the typist employed a special stand to hold the manuscript being typed. The idea of having a view of your work and then another surface to actually work on is used quite often throughout history because it’s a convenient way to perform tasks quickly. By employing dual monitors, I commonly get between a 15 percent to 33 percent increase in output, simply because I can see my work and its associated view at the same time.

Working with dual monitors not only saves time, but can also reduce errors. By typing as I view the output of applications, I can more reliably relate the text of labels and other information the application provides. The same holds true when viewing information sources found in other locations. Seeing the information as I type it is always less likely to produce errors.

Don’t get the idea that I support using dual monitors in every situation. Many consumer-oriented computer uses are served just fine with a single monitor. For example, there isn’t a good reason to use two monitors when viewing e-mail in many cases—at least, not at the consumer level (you could make a case for using dual monitors when working with e-mails and a calendar to manage tasks, for example). Dual monitors commonly see use in the business environment because people aren’t necessarily creating their own information source—the information comes from a variety of sources that the user must view in order to use reliably.

Do you see yourself using dual monitors? If you use such a setup now, how do you employ it? Let me know at


Choosing Variable Names

It often surprises me that developers seem to choose completely useless variable names like MyVariable when creating an application. Although MyVariable could be an interesting variable name for an example in a book, it never has a place in any sort of production code. Even then, I try to create book examples with meaningful variable names, especially when getting past the initial “Hello World” example. Variable names are important because they tell others:


  • What sort of information the variable stores
  • When the variable is commonly used
  • Where the variable is used
  • How to use the variable correctly
  • Why the variable is important

In some cases, the variable name could even indicate who created the variable; although, this sort of information is extremely rare. If you never thought a variable name should contain all that information, then perhaps you haven’t been choosing the best variable names for your application.

Even with these restrictions in place, choosing a variable name can be uncommonly hard if you want to maximize the name’s value to both yourself and other developers. Some organizations make the selection process easier by following certain conventions. For example, a form of Hungarian Notation, where certain type prefixes, suffixes, and other naming conventions are used, is a common way to reduce the complexity of creating a variable name. In fact, Hungarian Notation (or some form of it) is often used to name objects, methods, functions, classes, and other programming elements as well. For example, NamArCustomers could be an array of customer names (Nam for names, Ar for array). The use of these two prefixes would make it instantly apparent when the variable is being used incorrectly, such as assigning a list of numbers to the array. The point is that an organizational variable naming policy can reduce complexity, make the names easy to read for anyone, and reduces the time the developer spends choosing a name.


Before I get a ton of e-mail on the topic, yes, I know that many people view Hungarian notation as the worst possible way to name variables. They point out that it only really works with statically typed languages and that it doesn’t work at all for languages such as JavaScript. All that I’m really pointing out is that some sort of naming convention is helpful—whether you use something specific like Hungarian Notation is up to you.

Any variable name you create should convey the meaning of that variable to anyone. If you aren’t using some sort of pattern or policy to name the variables, then create a convention that helps you create the names in a consistent manner and document it. When you create a variable name, you need to consider these kinds of questions:


  1. What information does the variable contain (such as a list of names)?
  2. How is the variable used (such as locally or globally, or to contain coordinates, or a special kind of object)?
  3. When appropriate, what kind of information does the variable contain (such as a string or the coordinate of a pixel on screen)?
  4. Is the variable used for a special task (such as data conversion)?
  5. What case should prefixes, suffixes, and other naming elements appear in when a language is case sensitive?

The point is that you need to choose variable names with care so that you know what they mean later. Carefully chosen variable names make it possible for you to read your code with greater ease and locate bugs a lot faster. They also make it easier for others to understand your code and for you to remember what the code does months after you’ve written it. However, most important of all, useful variable names help you see immediately that a variable is being using the wrong way, such as assigning the length of a name string to a coordinate position on screen (even though both variables are integer values). Let me know your thoughts about variable naming at


Verifying Your Hand Typed Code

I maintain statistics for each of my books that are based on reviews and reader e-mails (so those e-mails you send really are important). These statistics help me write better books in the future and also help me determine the sorts of topics I need to address in my blog. It turns out that one of the most commonly asked questions is why a reader’s hand typed code doesn’t work. Some readers simply ask the question without giving me any details at all, which makes the question impossible to answer. In some cases, the reader sends the hand typed code, expecting that I’ll take time to troubleshoot it. However, this isn’t a realistic request because it defeats the very purpose behind typing the code by hand. If I take the time to diagnose the problems in the code you typed, I’ll be the one to learn an interesting lesson, not you. If you learn better by doing—that is, by typing the code by hand and then running it, then you need to be the one to troubleshoot any problems with the resulting code.

My advice to readers is to use the downloadable source code when working through the book text. If you want to type the code by hand after that as part of your learning experience, at least you’ll know that the example works on your system and you’ll also understand how the example works well enough to troubleshoot any errors in your own code. However, you need to be the one to diagnose the errors. If nothing else, perform a character-by-character comparison of your code to the example code that you downloaded from the publisher’s site. Often, a reader will write back after I suggest this approach and mention that they had no idea that a particular special symbol or method of formatting content was important. These are the sorts of lessons that this kind of exercise provide.

Now, it has happened that the downloadable source code doesn’t always work on a particular user’s system. When the error is in the code or something I can determine about the coding environment, you can be certain that I’ll post information about it on my blog. This should be the first place you look for such information. Simply click on the book title in question under the Technical category. You’ll find a list of posts for that book. Always feel free to contact me about a book-specific question. I want to be sure you have a good learning experience.

There are some situations where a reader tries to run application code that won’t work on a particular system. My books provide information on the kind of system you should use, but I can’t always determine exceptions to the rule in advance. When I post system requirements, your system must meet those requirements because the examples are guaranteed to fail on lesser systems. If you encounter a situation where the downloadable code won’t run on your system, but none of the fixes I post for that code work and your system does meet the requirements, then please feel free to contact me. There are times where an example simply won’t run because you can’t use the required software or the system won’t support it for whatever reason.

The point of this post is that you need to work with the downloadable source code whenever possible. The downloadable source code has been tested by a number of people, usually on a range of systems, to ensure it will work on your system too. I understand that typing the code by hand is an important and viable way to learn, but you should reserve this method as the second learning tier—used after you have tried the downloadable source code. Please let me know if you have any questions or concerns at


DateTimePicker Control Data Type Mismatch Problem

A reader recently made me aware of a problem with the Get User Favorites example in Chapter 2 that could cause a lot of problems depending on which language you use when working with Visual Studio 2012. This issue does affect some of the examples in Microsoft ADO.NET Entity Framework Step by Step so it’s really important you know about it.

Look at the model on page 30 of the book (the “Creating the model” section of Chapter 2). The Birthday field is defined as type DateTime. When you finish creating the model, you right click the resulting entity and choose Generate Database from Model to create a database from it. The “Working with the mapping details” section of Chapter 1 (page 19) tells you how to use the Generate Database Wizard to create the database. The Birthday field in the database will appear as a datetime type when you complete the wizard, which is precisely what you should get.

At this point, you begin creating the example form to test the database (the “Creating the test application” section on page 36). The example uses a DateTimePicker control for the Birthday field by default. You don’t add it, the IDE adds it for you because it sees that Birthday is a datetime data type. The example will compile just fine and you’ll be able to start it up as normal.

However, there is a problem that occurs when working with certain languages when you start the “Running the basic query” section that starts on page 39. The DateTimePicker control appears to send a datetime2 data type back to SQL Server when you change the birthday information. You’ll receive an exception that says the data types don’t match, which they don’t. There are several fixes for this problem. For example, you could coerce the output of the DateTimePicker control to output a datetime data type instead of a datetime2 data type. However, the easiest fix is to simply change the data type of the Birthday field in the database from datetime to datetime2. After you make this change, the example will work as it should. You only need to make this change when you see the data type mismatch exception. I haven’t been able to verify as of yet which languages are affected and would love to hear from my international readers about the issue.

As far as the book is concerned, this problem is quite fixable using the manual edit (although, manually editing the database shouldn’t be something you should have to do). However, it does bring up the question of how teams working across international boundaries will interact with each other if they can’t depend on the controls acting in a particular way every time they’re used. This is a problem that you need to be aware of when working with larger, international, teams. Let me know if you have any questions or concerns about the book example at You’ll have to contact Microsoft about potential fixes to the DateTimePicker control since I have no control over it.


Application Development and BYOD

I read an article a while ago in InforWorld entitled, “The unintended consequences of forced BYOD.” The Bring Your Own Device (BYOD) phenomenon will only gain in strength because more people are using their mobile devices for everything they do and corporations are continually looking for ways to improve the bottom line. The push from both sides ensures that BYOD will become a reality. The article made me think quite hard about how developers who work in the BYOD environment will face new challenges that developers haven’t even had to consider in the past.

Of course, developers have always had to consider security. Trying to maintain a secure environment has always been a problem. The only truly secure application is one that has no connectivity to anything, including the user. Obviously, none of the applications out there are truly secure—the developer has always had to settle for something less than the ideal situation. At least devices in the past were firmly under IT control, but not with BYOD. Now the developer has to face the fact that the application will run on just about any device, anywhere, at any time, and in any environment. A user could be working on company secrets with a competitor looking right at the screen. Worse, how will developers legal requirements such as the Health Insurance Portability and Accountability Act (HIPAA)? Is the user now considered an independent vendor or is the company still on the hook for maintaining a secure environment? The legal system has yet to address these sorts of questions, but it will have to do so soon because you can expect that your doctor (and other health professionals) will use a mobile device to enter information as well.

Developers will also have to get used to working with new tools and techniques. Desktop development has meant working with tools designed for a specific platform. A developer would use something like C# to create a desktop application meant for use on any platform that supports the .NET Framework, which mainly meant working with Windows unless the company also decided to support .NET Framework alternatives such as Mono (an open source version of the .NET Framework). Modern applications will very likely need to work on any platform, which means writing server-based applications, browser-based applications, or a combination of the two in order to ensure the maximum number of people possible can interact with the application. The developer will have to get used to the idea that there is no way to test absolutely every platform that will use the application because the next platform hasn’t been delivered yet.

Speed also becomes a problem for developers. When working with a PC or laptop, a developer can rely on the client having a certain level of functionality. Now the application needs to work equally well with a smartphone that may not have enough processing power to do much. In order to ensure the application works acceptably, the developer needs to consider using browser-based programming techniques that will work equally well on every device, no matter what level of power the device possesses.

Some in industry have begun advocating that BYOD should also include Bring Your Own Software (BYOS). This would mean creating an environment where developers would make data available through something like a Web service that could be accessed by any sort of device using any capable piece of software. However, the details of such a setup have yet to be worked out, much less implemented. The interface would have to be nearly automatic with regard to connectivity. The browser-based application could do this, but only if the organization could at least ensure that everyone would be required to use a browser that met minimum standards.

My current books, HTML5 Programming with JavaScript for Dummies and CSS3 for Dummies both address the needs of developers who are looking to move from the desktop into the browser-based world of applications that work anywhere, any time. Let me know your thoughts about BYOD and BYOS at


The Place of Automation in the User Interface

There was a time that a developer could rely on users to possess a certain level of technical acumen. That’s no longer the case. Most of the people using a device containing a CPU today (I’m including PCs, laptops, tablets, and smartphones here) don’t know anything about how it works and they don’t care to know either. All these people know is that they really must have access to their app. (Some don’t even realize the role data plays in making the app work.) The app can perform myriad tasks—everything from keeping track of the calories they’ve eaten to maintaining the scheduled events for the day. Devices that contain CPUs have become the irreplaceable partner for many people and these devices must work without much concern on the part of the user. In short, the device must provide a superior level of automation or the user simply won’t know how to interact with it.

I was recently watching television and saw a commercial for a Weight Watchers app for mobile devices. In the commercial, a woman exclaims wonder about the new programs that Weight Watchers provides, which include this app for her mobile devices. To track her calories, she simply points her phone at the box containing whatever food she plans to eat and the app tracks the calories for her. The interesting part is that there is no data entry required. As technology continues to progress, you can expect to see more apps of this type. People really don’t want to know anything about your app, how it works, or the cool code you put into it. They want to use the app without thinking about it at all.

Of all the parts of a device that must be automated, the user interface is most important and also the most difficult to create. Users really don’t want to have to think about the interface. Their focus is on the task that the app performs for them. In fact, some e-mails I’ve received recently about my Windows 8 book have driven home the idea that the app must simply work without any thought at all. It’s because of these e-mails (and those for other books I’ve written) that I wrote the article entitled, “Designing Apps with Automation in Mind.” This article points out the essential behaviors that applications must exhibit today to be successful.

On the other side of the fence, I continue to encounter an “old world” philosophy on the part of developers that applications should pack as much as possible into a small space—users will eventually figure out the complexity of the interface provided. Unfortunately, as users become more vocal in requiring IT to meet their demands, these approaches to the user interface will lose out. The next app is a click away and if it does the job of automating the interface better, your app will lose out. Even if there isn’t another app to use, the user will simply ignore the app you’ve provided. The user will rely on an older version or simply not interact with the app if there is no older version. Many organizations have found out the hard way that attempting to force users to interact with an app is bound to fail.

The fact is, to be successful today, a developer must be part psychologist, part graphics artist, and part programming genius. Creating an acceptable interface is no longer good enough, especially when people want to access the same app from more than one device. The interface must be simple, must work well, and must automate as much of the input as possible for the user or it simply won’t succeed. Let me know your thoughts about user interface automation at


Accessing Sample Database Data (Part 4)

The previous post, Accessing Sample Database Data (Part 3), discussed the need to change the connection string for a database in the App.CONFIG file. However, you haven’t actually gained access to the database as of yet. Depending on how the book is written, you may have to create the database using code and manually inputting the entries, run a script, or add a database file to SQL Server. Of the three, writing the database code and manually inputting the entries is the most straightforward. All you need to do is perform the instructions written in the book. As mentioned in my first post, many readers find this method the least acceptable because database management tasks of this sort are supposedly in the realm of DBAs.

In order to work with databases in Visual Studio, you must have a connection to the database. All of my books show how to create such a connection using Server Explorer. The project will not include a connection when you open the downloadable source code. The connection to the server is part of your Visual Studio setup and you must create it when you begin working with the downloadable source. The short take on creating a connection is to right click the Data Connections folder in Server Explorer and choose Add Connection from the context menu. You’ll see a wizard that will lead you through the steps for creating the connection.

Using Scripts

The next level of complexity is the script. A number of my books use scripts in order to make it at least reasonable to use something other than SQL Server as the database manager. More and more of my readers want to use other solutions. Accommodating this need is proving difficult, but using scripts does have the advantage of reducing the work required to use non-SQL Server solutions. I’m going to assume that you’re working with Visual Studio and that you have a connection to your database manager, whatever that database manager might be. The following steps tell how to use scripts in a general way (you may find slight variations in the steps between different versions of Visual Studio).

  1. Choose File | Open | File. You see an Open File dialog box.
  2. Highlight the script you want to use (a script always has a .SQL extension) and click Open. You see the script opened in Visual Studio.
  3. Right click anywhere in the editor window and choose Execute SQL from the context menu. Visual Studio interacts with your database manager to run the script.

Using a Database File

The third level of complexity is actually using a database file. The advantage of using this option is that the database is completely configured and contains everything needed to use it. This level represents the least amount of work on the part of the reader in most cases. It’s also the least flexible because it only works with SQL Server and the version of SQL Server must be able to support the features in the database file. Use these steps to work with a SQL Server database file from Visual Studio.

  1. Open Server Explorer by choosing View | Server Explorer. You see the Server Explorer window open as shown here.
  2. Right click Data Connections and choose Add Connection from the context menu. You see the Choose Data Source dialog box shown here.
  3. Select Microsoft SQL Server Database File. The wizard automatically chooses the correct Data Provider option for you. Click Continue. You see the Add Connection dialog box shown here.
  4. Click Browse. You see the Select SQL Server Database File dialog box shown here.
  5. Highlight the file you want to use and click Open. You return to the Add Connection dialog box.
  6. Click Test Connection. You should see a success message. If your version of SQL Server doesn’t support the features needed to use the database file, you’ll see an error message that states the file can’t be downgraded. The message will also tell you which version of SQL Server you require to use the database file.
  7. Click OK. Visual Studio creates the connection for you. What has actually happened in the background is that SQL Server has created the connection at the request of Visual Studio.


I try to choose the database option for my books with care. Many of my books use more  than one option to allow more people to work with the option that best suits their needs. However, it’s impossible to please everyone with the choices I make. When you encounter problems using one of the database options I’ve selected, I’ll try my best to help you work through the difficulties. As with every other aspect of my books, working with the databases is a learning experience. Let me know your thoughts on database access in my books or if you have additional database access questions at


Accessing Sample Database Data (Part 3)

The previous installment of this series, Accessing Sample Database Data (Part 2), discussed the Windows-specific setup required to use your database from Visual Studio. It includes setting the file for read/write usage and also verifying that you have permission to work with the files. This part of the series will discuss one of the most important settings within Visual Studio itself, the connection string. In order to use a data source from within a Visual Studio application, you must tell Visual Studio where to find the data source—a sensible requirement when you think about it.

The problem for me as an author who is trying to provide you with downloadable source code is that I have no idea of what SQL Server configuration you plan to use on your system. I can make some educated guesses, but that’s about it. So, there is every chance that the connection string is going to be wrong when it comes to the actual location of the data source on your system; especially when you use a different setup from the one in the book.

In most cases, you’re most interested in locating a string similar to data source=.\SQLEXPRESS in your application. This string normally appears in the App.Config file. Over the years I have tried a number of permutations of this string, but none work out quite so well as .\SQLEXPRESS. The period represents the local machine, but you can replace it with any machine name desired. For example, if you use a separate server named WinServer, you’d use WinServer\SQLEXPRESS instead of .\SQLEXPRESS.

The SQLEXPRESS part of the data source attribute is also dependent on your setup. When you install SQL Express on your system, it usually installs as a named instance called SQLEXPRESS. However, you could just as easily install it as the default instance or you might not use SQL Express at all. To specify that you want to use the default instance of SQL Server, you use a period (.). So the default instance on the local machine would appear as .\.. Otherwise, you must provide the name of a named instance of SQL Server to use.

There is always a question of whether you have found every instance of the data source string in your application. Newer versions of Visual Studio place the string in one location when you create a connection using a wizard, App.Config. However, depending on how the application is put together, you could conceivably find the string in other locations. To ferret out these other locations, use the FindStr utility at the command line. I describe how to use this utility to locate errors in your application code in the Using the FindStr Utility to Locate Errors in Visual Studio post. You can use precisely the same approach for locating the data source. In this case, you’d open a command prompt at the main folder for the downloadable source, type FindStr \m \s “\SQLEXPRESS” *.*, and press Enter. FindStr will locate all instances of that particular data source.

In order to change the example code so that it works with your system, you must modify the data source string wherever it appears in the sample code to match your particular system. Let me know if you encounter problems making this change at You can see the next post in this series at Accessing Sample Database Data (Part 4).


Accessing Sample Database Data (Part 2)

In my previous post, Accessing Sample Database Data (Part 1), you learned about the various ways in which an author can provide database examples as part of a learning experience. This post is going to look at the process for gaining access to the database files in Windows, no matter what sort of database is used (including XML databases). In order to perform the tasks in this post, you need a copy of Windows Explorer opened with Administrator privileges. Choose Start | All Programs | Accessories to see the Windows Explorer shortcut. Right click the Windows Explorer shortcut and choose Run As Administrator from the context menu. Provide the requires credentials (username and password) to run in administrator mode, if asked.

Checking File Access

Some of the databases you obtain for my books appear on a CD or other device that provides read-only access. When you copy the files from the CD or other device to your hard drive, Windows keeps the files set to read-only access. In order to use the files, you must be able to read and write them. To change this setting, right click the folder that holds the files and choose Properties from the context menu. You see a properties dialog box similar to the one shown here.


Clear the Read-only checkbox and click OK. You’ll see a Confirm Attribute Changes dialog box like the one shown here.


Make sure the Apply Changes to this Folder, Subfolders and Files options is selected. Click OK. Windows will make all of the files read/write so that you can work with them. If you see a User Account Control (UAC) dialog box telling you that Administrator permission is required, click Continue and provide the required credentials (username and password) if required.

Checking Folder Security

It’s essential that you check folder security to avoid all sorts of weird problems that arise when you don’t have access. Never assume you actually have access; always check it to be sure. Right click the folder holding the files and choose Properties. You see the Properties dialog box again. This time select the Security tab as shown here.


Make sure that your account, or a group account to which you belong, is listed in the Group or User Names list as having Full Control (as shown in the Permissions list in the bottom half of the dialog box). If you don’t have the required access, click Edit. You’ll see a Permissions dialog box for the affected folder as shown here.


Verify that your name or a group of which you are a part appears in the Group or User Names list. If not, click Add. You’ll see a Select Users or Groups dialog box like the one shown here.


Type your login name or the name of the group that should have access to the folder. Click Check Names to ensure you typed the name correctly. If you didn’t type the name correctly, Windows will tell you it didn’t find the name and provide you with another dialog box for searching for the correct name. Otherwise, you’ll see the fully qualified name used to access the folder. Once you have a correct name in place, click OK. You’ll see the Permissions dialog box again.

Select the name you want to use to access the folder from the list. Check the Full Control option in the Allow column of the Permissions list at the lower half of the Permissions dialog box. Click OK. If everything goes correctly, you’ll see the Security tab of the Properties dialog box again, but this time it will contain your selected group with full control access.

Something odd can happen and it confuses a lot of readers. You might see a dialog box similar to this one during the security setting process:


When you see this dialog box, it usually means that the SQL Server service is running and it has the requested file open. Click Continue for each of the disallowed changes to ensure that your folder remains in a usable state.

Now, open the Services console found in the Administrative Tools folder of the Control Panel. Locate the SQL Server service and click the Stop link on the left side of the right pane to stop the service as shown here.


Try setting the security again. If the error persists, you need to try to set the security on the individual database files using the same technique you tried to use for the folder as a whole. (When working with individual files, the security tab may display a message saying you need administrative privileges to view the individual file security. Simply click Continue to work with the privileges.) Yes, it’s a nuisance setting individual file security, but that’s the way Windows works at times. After you successfully set security on each of the database files, remember to restart the services that you stopped.

A number of readers stumble on these file access and security permission issues. Please let me know if this post solves the problems for you. If not, make sure you send your questions to You see see the next post in this series at Accessing Sample Database Data (Part 3).


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).