PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2007 by Dino Esposito All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or byany means without the written permission of the publisher. Library of Congress Control Number:2007924643 Printed and bound in the United States of America. 1 2 3 4 5 6 7 8 9 QWT 2 1 0 9 8 7 Distributed in Canada by H.B. Fenn and Company Ltd. A CIP catalogue record for this book is available from the British Library. Microsoft Press books are available through booksellers and distributors worldwide. For further infor- mation about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send comments to [email protected]. Microsoft, Microsoft Press, ActiveX, IntelliSense, Internet Explorer, MSDN, MSN, PowerPoint, SQL Server, Visual Basic, Visual C#, Visual C++, Visual Studio, Windows, Windows Media,and Windows Vistaare either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Other product and company names mentioned herein may be the trademarks of their respective owners. The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. (cid:55)(cid:75)(cid:76)(cid:86)(cid:3)(cid:69)(cid:82)(cid:82)(cid:78)(cid:3)(cid:72)(cid:91)(cid:83)(cid:85)(cid:72)(cid:86)(cid:86)(cid:72)(cid:86)(cid:3)(cid:87)(cid:75)(cid:72)(cid:3)(cid:68)(cid:88)(cid:87)(cid:75)(cid:82)(cid:85)(cid:182)(cid:86)(cid:3)(cid:89)(cid:76)(cid:72)(cid:90)(cid:86)(cid:3)(cid:68)(cid:81)(cid:71)(cid:3)(cid:82)(cid:83)(cid:76)(cid:81)(cid:76)(cid:82)(cid:81)(cid:86)(cid:17)(cid:3)(cid:55)(cid:75)(cid:72)(cid:3)(cid:76)(cid:81)(cid:73)(cid:82)(cid:85)(cid:80)(cid:68)(cid:87)(cid:76)(cid:82)(cid:81)(cid:3)(cid:70)(cid:82)(cid:81)(cid:87)(cid:68)(cid:76)(cid:81)(cid:72)(cid:71)(cid:3)(cid:76)(cid:81)(cid:3)(cid:87)(cid:75)(cid:76)(cid:86)(cid:3)(cid:69)(cid:82)(cid:82)(cid:78)(cid:3)(cid:76)(cid:86)(cid:3)(cid:83)(cid:85)(cid:82)(cid:89)(cid:76)(cid:71)(cid:72)(cid:71)(cid:3) without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Acquisitions Editor:Ben Ryan Developmental Editor: Lynn Finnel Editorial Production: Abshier House Copy Editor: Roger LeBlanc Technical Reviewer:Kenn Scribner Indexer:Sharon Hilgenberg Body Part No. X13-68385 Contents at a Glance ASP.NET AJAX Building Blocks Part I 1 The AJAX Revolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 2 The Microsoft Client Library for AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Adding AJAX Capabilities to a Site Part II 3 The Pulsing Heart of ASP.NET AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 4 Partial Page Rendering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 5 The AJAX Control Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Client-Centric Development Part II 6 Built-in Application Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 7 Remote Method Calls with ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . 233 8 Building AJAX Applications with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . 267 Table of Contents Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii ASP.NET AJAX Building Blocks Part I 1 The AJAX Revolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 The Paradigm Shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Classic Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 AJAX-Based Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 The Role of Rich Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 The AJAX Core Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 The XMLHttpRequest Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 Roll Your Own (Little) AJAX Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16 An HTTP Object Model. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 The Switch to the Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 Existing AJAX Frameworks for ASP.NET. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24 ASP.NET AJAX in Person. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30 Setting Up ASP.NET AJAX Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31 Core Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34 What do you think of this book? We want to hear from you! Microsoft is interested in hearing your feedback so we can continually improve our books and learning resources for you. To participate in a brief online survey, please visit: www.microsoft.com/learning/booksurvey/ viii Table of Contents 2 The Microsoft Client Library for AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 JavaScript Language Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Infrastructure for Extensions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Object-Oriented Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Core Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 The Sys.Application Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 The Sys.Component Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 The Network Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 User-Interface Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Other Components and Functionalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Adding AJAX Capabilities to a Site Part II 3 The Pulsing Heart of ASP.NET AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Configuration of ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 The web.config File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 The Runtime Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 The Script Manager Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 The ASP.NET ScriptManager Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Script Loading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 Script Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 4 Partial Page Rendering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Defining Updatable Regions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Generalities of the UpdatePanel Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 Enabling Partial Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Testing the UpdatePanel Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 The Mechanics of Updatable Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Taking Control of Updatable Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Triggering the Panel Update. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Triggering Periodic Partial Updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Providing User Feedback During Partial Updates . . . . . . . . . . . . . . . . . . . . . . . 121 Client-Side Events for a Partial Update. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Passing Data Items during Partial Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Animating Panels during Partial Updates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Table of Contents ix 5 The AJAX Control Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Extender Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140 What Is an Extender, Anyway?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .140 The ExtenderControl Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142 Creating a Sample Extender. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .144 Introducing the AJAX Control Toolkit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .150 Get Ready for the Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151 What’s in the AJAX Control Toolkit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154 The Accordion Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 Generalities of the Accordion Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .157 Using the Accordion Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .159 The Rating Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .160 Generalities of the Rating Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161 Using the Rating Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162 The ReorderList Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Generalities of the ReorderList Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .164 Using the ReorderList Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166 The TabContainer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Generalities of the TabContainer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169 Using the TabContainer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .170 AJAX Control Toolkit Extenders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 Panel Extenders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172 Button Extenders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175 Pop-up Extenders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178 User-Interface Extenders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183 Input Extenders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .191 Animation Extenders. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205 Client-Centric Development Part III 6 Built-In Application Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 Forms Authentication Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210 The System Infrastructure for Authentication. . . . . . . . . . . . . . . . . . . . . . . . . . .210 Using the Authentication Service in an Application . . . . . . . . . . . . . . . . . . . . .214 User Profiling Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222 The System Infrastructure for Profiling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .223 x Table of Contents Using the Profile Service in an Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 7 Remote Method Calls with ASP.NET AJAX . . . . . . . . . . . . . . . . . . . . . . . 233 Designing the Server API for Remote Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 Defining the Contract of the Remote API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 Implementing the Contract of the Remote API. . . . . . . . . . . . . . . . . . . . . . . . . 236 Remote Calls via Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 Creating an AJAX Web Service. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Consuming AJAX Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Considerations for AJAX Web Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Remote Calls via Page Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Creating Page Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Consuming Page Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253 Bridging External Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256 Traditional Server-to-Server Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 ASP.NET AJAX Futures Bridge Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 8 Building AJAX Applications with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . 267 AJAX in Perspective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 The Benefits of AJAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268 The Downsides of AJAX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 Patterns, Practices, and Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273 Revisiting ASP.NET Starter Kits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 The Jobs Site Starter Kit at a Glance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 Reducing Page Flickering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Periodic Screen Refresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 Conclusion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .295 What do you think of this book? We want to hear from you! Microsoft is interested in hearing your feedback so we can continually improve our books and learning resources for you. To participate in a brief online survey, please visit: www.microsoft.com/learning/booksurvey/ Introduction AJAX stands for “Asynchronous JavaScript and XML,” and it’s a sort of blanket term coined in 2005 to indicate rich, highly interactive, and responsive Web applications that do a lot of work on the client and place out-of-band calls to the server. An out-of-band call is a server request that results in a page update rather than a page replacement. The net effect is that an AJAX Web application tends to look like a classic desktop Microsoft Windows application and has advanced features such as drag-and-drop and asynchronous tasks, a strongly responsive and nonflickering user interface, and far less user frustration. ASP.NET AJAX Extensions is a significant extension to the ASP.NET platform that makes AJAX-style functionalities possible and effective. ASP.NET AJAX Extensions is designed to be part of ASP.NET and, therefore, seamlessly integrate with the existing platform and applica- tion model. Architecturally speaking, the ASP.NET AJAX framework is made of two distinct elements: a client script library and a set of server extensions. The client script library is entirely written in JavaScript and, therefore, works with any modern browser. Server extensions are fully inte- grated with ASP.NET server-based services and controls. As a result, developers can write rich Web pages using nearly the same approach they know from developing classic ASP.NET server-based pages. Most ASP.NET AJAX developers are former ASP.NET developers and, as such, are familiar with the server-side development model based on controls. The server-centric programming model is the next big step in the evolution of the ASP.NET programming model. ASP.NET AJAX server controls are great, especially if you don’t feel confident enough to create AJAX client scripts manually. This book provides an overview of the ASP.NET AJAX framework with numerous examples to familiarize you with a variety of techniques and tools. AJAX is a real breakthrough for ASP.NET developers and professionals. It makes cross-browser programming a reality and enables desktop-like functionalities over the Web. Who This Book Is For The book is recommended for virtually any ASP.NET developer and professional. As men- tioned, ASP.NET AJAX is the next big thing in the ASP.NET evolution and follows a key indus- try trend—the AJAX model. In addition, ASP.NET AJAX goes beyond the classic AJAX model, pushing a framework that spans the client and server to provide an end-to-end solution for Web applications. As far as the Microsoft Web platform is concerned, ASP.NET AJAX Exten- sions weds rich functions with wide reach—an old dream of Web professionals that comes true. At last. xiii xiv Introduction If you’re a Web professional developing for Microsoft-based Web technologies, AJAX is your next big opportunity to seize. This book is your starting point. And even a bit more. How This Book Is Organized The book is divided into three parts: an overview of the platform and its building blocks, tech- niques to effectively enhance existing sites, and client-centric development. In the first part, you’ll learn the basics of the AJAX model and the extensions made to the JavaScript language to back it. The second part is dedicated to the elements in the framework that you use to add new capabilities to existing server controls and to transform existing classic ASP.NET pages into full-fledged AJAX pages. Finally, the third part covers tools and techniques that express the real power of AJAX applications—out-of-band calls to server code. System Requirements You’ll need the following hardware and software to build and run the code samples for thisbook: ■ Microsoft Windows Vista, Microsoft Windows XP with Service Pack 2, Microsoft Win- dows Server 2003 with Service Pack 1, or Microsoft Windows 2000 with Service Pack 4 ■ Microsoft Visual Studio 2005 Standard Edition or Microsoft Visual Studio 2005 Profes- sional Edition ■ Microsoft SQL Server 2005 Express (included with Visual Studio 2005) or Microsoft SQL Server 2005 ■ 600-MHz Pentium or compatible processor (1-GHz Pentium recommended) ■ 192 MB of RAM (256 MB or more recommended) ■ Video monitor (800 x 600 or higher resolution) with at least 256 colors (1024 x 768 High Color 16-bit recommended) ■ Microsoft mouse or compatible pointing device Configuring SQL Server 2005 Express Edition Some chapters of this book require that you have access to SQL Server 2005 Express Edition (or SQL Server 2005) to create and use the Northwind Traders database. If you are using SQL Server 2005 Express Edition, follow these steps to grant access to the user account that you will be using to perform the exercises in this book: 1. Log on to Windows on your computer by using an account with administrator privileges. Introduction xv 2. On the Windows Start menu, click All Programs, click Accessories, and then click Com- mand Prompt to open a command prompt window. 3. In the command prompt window, type the following case-sensitive command: sqlcmd –S YourServer\SQLExpress –E Replace YourServer with the name of your computer. You can find the name of your computer by running the hostname command in the com- mand prompt window before running the sqlcmd command. 4. At the 1> prompt, type the following command, including the square brackets, and then pressEnter: sp_grantlogin [YourServer\UserName] Replace YourServer with the name of your computer, and replace UserName with the name of the user account you will be using. 5. At the 2> prompt, type the following command and then press Enter: go If you see an error message, make sure that you have typed the sp_grantlogin com- mand correctly, including the square brackets. 6. At the 1> prompt, type the following command, including the square brackets, and then press Enter: sp_addsrvrolemember [YourServer\UserName], dbcreator 7. At the 2> prompt, type the following command and then press Enter: go If you see an error message, make sure that you have typed the sp_addsrvrolemember command correctly, including the square brackets. 8. At the 1> prompt, type the following command and then press Enter: exit 9. Close the command prompt window. 10. Log out of the administrator account. The Northwind Traders database no longer ships with SQL Server 2005 (either version), so you’ll need to download that separately. You can download the necessary installation scripts for the Northwind database from http://www.microsoft.com/downloads/details.aspx?FamilyId= 06616212-0356-46A0-8DA2-EEBC53A68034&displaylang=en. Installation instructions are included on the download page.
Description: