- •Preface
- •Who Should Read This Book
- •Organization and Presentation
- •Contacting the Authors
- •Acknowledgments
- •Contents
- •Introduction
- •Why Microsoft .NET?
- •The Microsoft .NET Architecture
- •Internet Standards
- •The Evolution of ASP
- •The Benefits of ASP.NET
- •What Is .NET?
- •.NET Experiences
- •.NET Clients
- •.NET Services
- •.NET Servers
- •Review
- •Quiz Yourself
- •Installation Requirements
- •Installing ASP.NET and ADO.NET
- •Installing the .NET Framework SDK
- •Testing Your Installation
- •Support for .NET
- •Review
- •Quiz Yourself
- •Designing a Database
- •Normalization of Data
- •Security Considerations
- •Review
- •Quiz Yourself
- •Creating a Database
- •Creating SQL Server Tables
- •Creating a View
- •Creating a Stored Procedure
- •Creating a Trigger
- •Review
- •Quiz Yourself
- •INSERT Statements
- •DELETE Statements
- •UPDATE Statements
- •SELECT Statements
- •Review
- •Quiz Yourself
- •The XML Design Specs
- •The Structure of XML Documents
- •XML Syntax
- •XML and the .NET Framework
- •Review
- •Quiz Yourself
- •ASP.NET Events
- •Page Directives
- •Namespaces
- •Choosing a Language
- •Review
- •Quiz Yourself
- •Introducing HTML Controls
- •Using HTML controls
- •How HTML controls work
- •Intrinsic HTML controls
- •HTML Control Events
- •The Page_OnLoad event
- •Custom event handlers
- •Review
- •Quiz Yourself
- •Intrinsic Controls
- •Using intrinsic controls
- •Handling intrinsic Web control events
- •List Controls
- •Rich Controls
- •Review
- •Quiz Yourself
- •Creating a User Control
- •Adding User Control Properties
- •Writing Custom Control Methods
- •Implementing User Control Events
- •Review
- •Quiz Yourself
- •Common Aspects of Validation Controls
- •Display property
- •Type Property
- •Operator Property
- •Using Validation Controls
- •RequiredFieldValidator
- •RegularExpressionValidator
- •CompareValidator
- •RangeValidator
- •CustomValidator
- •ValidationSummaryx
- •Review
- •Quiz Yourself
- •Maintaining State Out of Process for Scalability
- •No More Cookies but Plenty of Milk!
- •Out of Process State Management
- •Review
- •Quiz Yourself
- •Introducing the Key Security Mechanisms
- •Web.config and Security
- •Special identities
- •Using request types to limit access
- •New Tricks for Forms-based Authentication
- •Using the Passport Authentication Provider
- •Review
- •Quiz Yourself
- •ASP.NET Updates to the ASP Response Model
- •Caching with ASP.NET
- •Page Output Caching
- •Absolute cache expiration
- •Sliding cache expiration
- •Fragment Caching
- •Page Data Caching
- •Expiration
- •File and Key Dependency and Scavenging
- •Review
- •Quiz Yourself
- •A Brief History of Microsoft Data Access
- •Differences between ADO and ADO.NET
- •Transmission formats
- •Connected versus disconnected datasets
- •COM marshaling versus text-based data transmission
- •Variant versus strongly typed data
- •Data schema
- •ADO.NET Managed Provider Versus SQL Managed Provider
- •Review
- •Quiz Yourself
- •Review
- •Quiz Yourself
- •Creating a Connection
- •Opening a Connection
- •Using Transactions
- •Review
- •Quiz Yourself
- •Building a Command
- •Connection property
- •CommandText property
- •CommandType property
- •CommandTimeout property
- •Appending parameters
- •Executing a Command
- •ExecuteNonQuery method
- •Prepare method
- •ExecuteReader method
- •Review
- •Quiz Yourself
- •Introducing DataReaders
- •Using DataReader Properties
- •Item property
- •FieldCount property
- •IsClosed property
- •RecordsAffected property
- •Using DataReader Methods
- •Read method
- •GetValue method
- •Get[Data Type] methods
- •GetOrdinal method
- •GetName method
- •Close method
- •Review
- •Quiz Yourself
- •Constructing a DataAdapter Object
- •SelectCommand property
- •UpdateCommand, DeleteCommand, and InsertCommand properties
- •Fill method
- •Update method
- •Dispose method
- •Using DataSet Objects
- •DataSetName property
- •CaseSensitive property
- •Review
- •Quiz Yourself
- •Constructing a DataSet
- •Tables property
- •TablesCollection Object
- •Count property
- •Item property
- •Contains method
- •CanRemove method
- •Remove method
- •Add method
- •DataTable Objects
- •CaseSensitive property
- •ChildRelations property
- •Columns property
- •Constraints property
- •DataSet property
- •DefaultView property
- •ParentRelations property
- •PrimaryKey property
- •Rows property
- •Dispose method
- •NewRow method
- •Review
- •Quiz Yourself
- •What Is Data Binding?
- •Binding to Arrays and Extended Object Types
- •Binding to Database Data
- •Binding to XML
- •TreeView Control
- •Implement the TreeView server control
- •Review
- •Quiz Yourself
- •DataGrid Control Basics
- •Binding a set of data to a DataGrid control
- •Formatting the output of a DataGrid control
- •Master/Detail Relationships with the DataGrid Control
- •Populating the Master control
- •Filtering the detail listing
- •Review
- •QUIZ YOURSELF
- •Updating Your Data
- •Handling the OnEditCommand Event
- •Handling the OnCancelCommand Event
- •Handling the OnUpdateCommand Event
- •Checking that the user input has been validated
- •Executing the update process
- •Deleting Data with the OnDeleteCommand Event
- •Sorting Columns with the DataGrid Control
- •Review
- •Quiz Yourself
- •What Is Data Shaping?
- •Why Shape Your Data?
- •DataSet Object
- •Shaping Data with the Relations Method
- •Review
- •Quiz Yourself
- •OLEDBError Object Description
- •OLEDBError Object Properties
- •OLEDBError Object Methods
- •OLEDBException Properties
- •Writing Errors to the Event Log
- •Review
- •Quiz Yourself
- •Introducing SOAP
- •Accessing Remote Data with SOAP
- •SOAP Discovery (DISCO)
- •Web Service Description Language (WSDL)
- •Using SOAP with ASP.NET
- •Review
- •Quiz Yourself
- •Developing a Web Service
- •Consuming a Web Service
- •Review
- •Quiz Yourself
- •ASP and ASP.NET Compatibility
- •Scripting language limitations
- •Rendering HTML page elements
- •Using script blocks
- •Syntax differences and language modifications
- •Running ASP Pages under Microsoft.NET
- •Using VB6 Components with ASP.NET
- •Review
- •Quiz Yourself
- •Preparing a Migration Path
- •ADO and ADO.NET Compatibility
- •Running ADO under ASP.NET
- •Early Binding ADO COM Objects in ASP.NET
- •Review
- •Quiz Yourself
- •Answers to Part Reviews
- •Friday Evening Review Answers
- •Saturday Morning Review Answers
- •Saturday Afternoon Review Answers
- •Saturday Evening Review Answers
- •Sunday Morning Review Answers
- •Sunday Afternoon Review Answers
- •What’s on the CD-ROM
- •System Requirements
- •Using the CD with Windows
- •What’s on the CD
- •The Software Directory
- •Troubleshooting
- •ADO.NET Class Descriptions
- •Coding Differences in ASP and ASP.NET
- •Retrieving a Table from a Database
- •Displaying a Table from a Database
- •Variable Declarations
- •Statements
- •Comments
- •Indexed Property Access
- •Using Arrays
- •Initializing Variables
- •If Statements
- •Case Statements
- •For Loops
- •While Loops
- •String Concatenation
- •Error Handling
- •Conversion of Variable Types
- •Index
Introduction
With the release of the .NET Framework, Microsoft is taking the most significant risk in its history. Microsoft has spent billions of dollars, representing over 80 percent of its R&D budget, on designing and constructing this fundamental shift in its develop-
ment tools in order to build a framework for the future of application development. Microsoft has effectively realized its vision of Windows in every PC and a PC on every desktop. Its current problem is that the desktop represents only a portion of the new Internet universe. With the huge shift brought on by the Internet and its pervasiveness into everything from watches to cell phones to cars, Microsoft must now shift its view of the future from a PC-centric orientation to a service-centric orientation.
So what is the future? From Microsoft’s point of view, the future is delivering software as a service. Instead of purchasing a shrink-wrapped installable solution, you will instead rent, borrow, or purchase application logic across a distributed network. Software will of course still be sold on store shelves. However, most, if not all of the business logic and power of these applications will reside across a set of distributed applications using open Internetbased standards such as XML and HTTP. This framework will open extensive new possibilities for you in the process of designing, constructing, delivering, licensing, and collecting fees for your software.
Why Microsoft .NET?
Why would you as a developer invest in learning and understanding this new foundation of products and services? Those of you who are practicing solution developers already probably have a code base of Windowsand Internet-based applications written in Visual Basic, ASP, C++, or a combination of all three. If you have to address Windows API calls from C++ and Visual Basic and then integrate those calls as a COM component called by an ASP page, you will be amazed at how the .NET Framework–based classes provide a common approach and object model to accessing Windows services and resources. You will be further impressed at how the choice of development languages is no longer dependent upon power, flexibility, or support of OOP best practices. Now all languages compile to a Microsoft Intermediate Language (MSIL) and execute against a Common Language Runtime (CLR).
xviii |
Introduction |
To those familiar with Java, this will seem very interesting. Because there is an intermediate language, Microsoft needs only to provide support for the CLR on multiple platforms in order to provide full cross-platform portability. While at the time of this writing there were no major announcements in this area, it is anticipated that ports to Linux and other operating systems is a key way Microsoft will be able to recoup its investment. In fact, Microsoft has a migration kit, the Java User Migration Path or JUMP, which contains a set of tools that will enable Java developers to take advantage of the .NET platform. The stated goal of these tools is to provide a path for Visual J++ and other Java developers to preserve their existing Java language projects and migrate those projects to the .NET platform. Once you begin experimenting with C# you will clearly see how realistic it is for this type of approach to affect the Java community.
The Microsoft .NET Architecture
The Microsoft .NET Architecture is split into three essential areas:
The .NET platform, which includes the .NET infrastructure and tools to build and operate a new generation of Web services and applications. The core of the .NET platform is the .NET Framework, which includes C#, VB .NET, ASP.NET, and ADO.NET.
.NET products and services, which include Microsoft Windows, MSN.NET, personal subscription services, Microsoft Office .NET, Microsoft Visual Studio .NET, and Microsoft bCentral for .NET.
Third-party .NET services, which are services created by a vast range of partners and developers who now have the opportunity to produce corporate and vertical services built on the .NET platform.
The .NET platform contains all of the building blocks for creating .NET products and services and integrating third-party .NET solutions. Microsoft is using components of the .NET platform to extend the platform itself and to build additional .NET products. For example, as a developer you will be very impressed or possibly amazed that the entire ASP.NET platform is actually built on C#, which is a new .NET language! Additionally, large portions of the Visual Studio .NET code base are built on a combination of C++, C#, and VB .NET.
One of the most common themes heard throughout the development community concerns the stability of the .NET products and services. Compared with prior shifts in technology, such as when Microsoft moved from a 16-bit architecture to a 32-bit architecture or from DOS to Windows, this round is much more bearable.
.NET servers and applications
Microsoft’s .NET servers can be split into two primary categories: core services platforms and specialized services. The core services platforms form the underpinnings of a traditional Microsoft-centric application, including Windows 2000, SQL Server 2000, and Exchange 2000. These applications are .NET in that they robustly support XML plumbing at the core of their applications and provide the foundation for building distributed applications. The second category of servers provides specialized services. The BizTalk Server 2000, for instance, leverages a higher-level language called XLANG that enables you to define process flows, transaction flows, and contracts. XLANG also allows very deep integration across
Introduction |
xix |
inte-
specific, open
users
Identity application.
any parcan
.
of a Why for
. Some components,
book on of
ASP.NET
Database Programming
Weekend Crash Course™
Part I — Friday Evening
Session 1
Introducing ASP.NET
Session 2
Setting Up .NET
Session 3
Designing a Database
Session 4
Building a Database
P A R T
I
Friday
Evening
Session 1
Introducing ASP.NET
Session 2
Setting Up .NET
Session 3
Designing a Database
Session 4
Building a Database