Share via


Toolbox

Realistic Test Data, Dare Obasanjo’s Blog, Color-Coding Tools, and More

Scott Mitchell

All prices were confirmed August 21, 2008, and are subject to change. The opinions expressed in this column are solely those of the author and do not necessarily reflect the opinions at Microsoft.

Contents

Create Database Test Data
Blogs of Note
Displaying Color-Coded Syntax in a Web Page
The Bookshelf

Create Database Test Data

When building and testing a data-driven application, it is important that the data in the development database is an accurate reflection of the data that will be used in production. Having similar amounts and types of data during development and production helps designers to better evaluate user interfaces, developers to judge how well the system will scale, and testers to build test cases based on more realistic scenarios. It also helps to have realistic data for demos and sales presentations.

While you can write your own SQL scripts to generate test data, a much easier and faster approach is to use SQL Data Generator (version 1.1) from Red Gate Software. With a few points and clicks of the mouse, SQL Data Generator can generate millions of records with realistic values, and customizing the generated data is a cinch.

To get started, launch SQL Data Generator and create a new project, which displays the Project Configuration wizard. From here you select the server and database, indicate whether to have any custom SQL scripts execute before or after the data is generated, and choose an assortment of options, such as whether to fire INSERT and DELETE triggers and whether to enforce CHECK constraints.

After choosing the database and options, SQL Data Generator displays a three-pane interface. The left pane lists the tables in the database and enables you to select which tables will have data generated for them. Selecting a table from the left pane loads information about that table in the right two panes. The top-right pane summarizes the data-generation settings for the table. Here you can choose how many rows to add, whether to delete the table's data before adding the generated data, and what action to take if attempting to insert invalid data. The bottom-right pane shows a preview of the data that will be generated.

To customize the data for a particular table column, select that column from the left or bottom-right panes. This loads the column's settings in the upper-right pane. From here you can indicate whether the generated values for this column should be unique and what percentage of values should be NULL. You can also specify how the data is generated to ensure that it contains realistic values instead of just random strings, numbers, and dates. You can pull data from a .csv file, a SQL query, a weighted list of possible values, or from a regular expression.

Alternatively, you can pick a category, such as colors, e-mail addresses, first names, last names, addresses, cities, postal codes, credit card numbers, company names, or URLs, and SQL Data Generator will use pre-defined values that belong to that category. While you certainly can choose how each column in every table is generated, the good news is that SQL Data Generator makes an educated guess at the appropriate value based on the table and column names and data types. For example, when generating data for a string-based column named FirstName, SQL Data Generator will use values from the First Name category.

After reviewing the settings, click the Generate Data button to add the data to the selected tables. Generating voluminous amounts of database data is quick and easy with SQL Data Generator.

Price: $295.

go.microsoft.com/fwlink/?LinkId=124071

mitchell.toolbox.sqldatagenerator.gif

SQL Data Generator Generates and Customizes Data Records (Click the image for a larger view)

Blogs of Note

It's amazing how popular social software has become in the past several years. Just about everyone has a blog, and sites like Facebook, LinkedIn, and Blogger.com are some of the most visited sites on the Internet. Most social software makes use of Web services, XML, and other open standards to syndicate content and enable integration with third-party applications. For insights into these technologies and related development topics, look no further than Dare Obasanjo's blog.

Dare has years of experience assessing and working with different social software standards. He currently works as a Program Manager for the Microsoft Contacts team, which focuses on back-end services for Windows Live Messenger and Windows Live Spaces, and has worked on the XML and XML Schemas APIs in the Microsoft .NET Framework. Dare is also the creator of RSS Bandit, a popular RSS aggregator. Given his background, Dare has a lot of interesting insights into the standards used by social software, as well as tips and suggestions for those programming against these standards.

Reading Dare's blog can, at times, be like taking a sip from a fire hose. Dare adds a new blog entry almost every day of the week, and most of them are lengthy and packed full of information. But if you want a better understanding of how social software works and a deeper appreciation of the standards involved, Dare's blog is a must-stop destination.

25hoursaday.com/weblog

Displaying Color-Coded Syntax in a Web Page

All modern programming environments use color coding to improve the readability of source code. Visual Studio displays keywords, types, strings, and comments using different colors, and you can customize the fonts, sizes, and styles for these and other tokens. Yet many print and online code samples lack any color coding.

The extra costs associated with color printing may explain the lack of syntax highlighting in books and computer trade magazines, but why don't more blogs and Web sites color code source code samples? The primary challenge of syntax highlighting in a Web page is generating the appropriate HTML and CSS; however, there are a number of free tools that make this process a walk in the park.

One option is to use an online syntax highlighting service, such as Quick Highlighter (go.microsoft.com/fwlink/?LinkId=124072). Quick Highlighter's interface consists of a large textbox where you enter the code to format, a drop-down list with 96 different programming languages to choose from, and a handful of formatting options. It generates the HTML and CSS to color code the syntax, which you can paste into your blog entry or Web page.

One of my favorite color-coding tools is CopySourceAsHtml, a Visual Studio add-in by Colin Coller (read more about it at copysourceashtml.codeplex.com/). With CopySourceAsHtml there's no need to visit a Web page to color code your syntax; instead, you can generate the HTML and CSS from Visual Studio.

Simply select the code to format, right-click, and then choose the Copy As HTML menu option. This brings up a dialog box with various formatting options. Clicking OK generates the corresponding HTML and CSS and copies it to the Windows Clipboard. (Colin's last update to CopySourceAsHtml was before Visual Studio 2008 was released. Guy Burstein has created a Visual Studio 2008 compatible version, which you can download at go.microsoft.com/fwlink/?LinkId=124074.)

You can also highlight syntax from server-side code in your ASP.NET page. With the squishySyntaxHighlighter component from squishyWARE (go.microsoft.com/fwlink/?LinkId=124076) and two lines of code, you can turn a string of plain C#, Visual Basic, or XML syntax into highlighted HTML and CSS markup.

Price: All free.

mitchell.toolbox.quickhighligher.gif

Quick Highlighter Is an Online Syntax Highlighting Service (Click the image for a larger view)

The Bookshelf

ADO.NET is a conglomeration of classes within the System.Data and System.Xml namespaces that enable developers to programmatically query, insert, update, and delete data from a variety of data stores. There was a time when every developer working on a data-driven application needed a solid grounding in ADO.NET. However, as .NET has matured, a number of tools and application architectures from Microsoft and the community have encapsulated many of ADO.NET's low-level details and complexity. But don't forget all about ADO.NET just yet—there's still quite a bit of application code out there that uses ADO.NET, and having a solid understanding of the technology is important if you ever need to extend an existing architecture's data access layer functionality.

When I write or maintain ADO.NET code, I like to keep a copy of Bill Hamilton's book ADO.NET 3.5 Cookbook (O'Reilly, 2008) within arm's reach. ADO.NET 3.5 Cookbook offers more than 200 recipes for common ADO.NET problems—everything from where to store database connection strings to how to execute a SQL statement asynchronously. When I get stuck trying to recall how to perform a certain action, I reach for this book, flip to the Table of Contents, find the recipe, and am off and running.

Each recipe starts with a problem statement, such as: "You want to access an output parameter returned by a stored procedure." Next is the solution, and then the discussion. This problem/solution/discussion format results in self-contained recipes that are easy to understand. Moreover, the author presents virtually all solutions as console applications, as opposed to a Windows Forms or a Web application. This streamlines the solution section because there's no need to step through creating a user interface.

If you need a book that provides deep insights into the architectural decisions behind ADO.NET, or if you are looking for a book that focuses on new ADO.NET 3.5 features , such as LINQ, this book is not for you. But if you are looking for a reference book that you can use to find solutions to common problems quickly, pick up a copy of ADO.NET 3.5 Cookbook.

Price: $54.99.

go.microsoft.com/fwlink/?LinkId=124077

Send your questions and comments for Scott to toolsmm@microsoft.com.

Scott Mitchell, author of numerous books and founder of 4GuysFromRolla.com, is an MVP who has been working with Microsoft Web technologies since 1998. Scott is an independent consultant, trainer, and writer. Reach him at Mitchell@4guysfromrolla.com or via his blog at ScottOnWriting.NET.