A Programmer's Guide to ADO .NET in C#

( 4 )

Overview

This is the book on ADO.NET! ADO.NET is the latest database technology from Microsoft and is the most powerful way to manipulate a database to date. A Programmer's Guide to ADO.NET in C# begins by taking readers through an overview of C# and then delves into ADO.NET. Mahesh Chand provides details on how to use each of .NET's major data providers, including OLE DB, SQL Server, and the release version of ODBC. This book also serves as a great reference for the methods and ...
See more details below
Paperback
$33.26
BN.com price
(Save 26%)$44.95 List Price
Other sellers (Paperback)
  • All (25) from $1.99   
  • New (11) from $25.62   
  • Used (14) from $1.99   
Sending request ...

Overview

This is the book on ADO.NET! ADO.NET is the latest database technology from Microsoft and is the most powerful way to manipulate a database to date. A Programmer's Guide to ADO.NET in C# begins by taking readers through an overview of C# and then delves into ADO.NET. Mahesh Chand provides details on how to use each of .NET's major data providers, including OLE DB, SQL Server, and the release version of ODBC. This book also serves as a great reference for the methods and properties associated with these data providers' classes.

In addition, Chand shows C# programmers how to work with XML classes, integrate XML into the ADO.NET architecture, and use the power of XML to transfer, read, and store data. A Programmer's Guide to ADO.NET in C# provides developers with handy ideas for taking advantage of the Visual Studio .NET IDE and for tying data to myriad, powerful Windows Forms and Web Forms, including the multifaceted DataGrid control. Chand also discusses how you can use ADO.NET to develop Web applications and create Web services. Easy-to-follow, visually rich examples illustrate how to create and execute stored procedures, work with triggers and views, create and update tables, and perform event handling in ADO.NET. Chand also guides you through the development of a Web-based guest book.

About the Author:

Mahesh Chand is a software developer with Kruse Inc., a document-management software company, and is also an MCP in Visual C++ 6.0. He's the founder of both Mindcracker and C# Corner, a premier online resource for C# and .NET developers. Chand has a master's degree in computer science and a bachelor's degree in mathematics

Read More Show Less

Product Details

  • ISBN-13: 9781893115392
  • Publisher: Apress
  • Publication date: 4/18/2002
  • Pages: 740
  • Product dimensions: 7.42 (w) x 9.29 (h) x 1.59 (d)

Meet the Author

Mahesh Chand is presently engaged with Kruse. Inc. as a software developer. He has been working with Microsoft database technologies including ODBC, DAO, ADO, and OLE-DB for over 5 years. He has a M.S. degree in Computer Science and a B.S. in Mathematics. He is also an MCP in VC++ 6.0. Mahesh is also the founder of Mindcracker (http://www.mindcracker.com) and C# Corner (http://www.c-sharpcorner.com), a premier online resource for C# and .NET developers. In addition to his day job, Mahesh writes and program for C# Corner on C#, VB .NET, ASP .NET and other .NET technologies and help site visitors.
Read More Show Less

Read an Excerpt

Chapter 1: Introduction to C#

This chapter will introduce you to C#. You'll learn how to write and compile C# programs, C# syntaxes, data types, control flow, classes and their members, interfaces, arrays, and exception handling. I'll begin with an overview of the language.

Understanding the C# Language

Microsoft developed C#, a new programming language based on the C and C++ languages. Microsoft describes C# in this way: "C# is a simple, modern, object-oriented, and typesafe programming language derived from C and C++. C# (pronounced C sharp) is firmly planted in the C and C++ family tree of languages and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++."

Anders Hejlsberg, the principal architect of C#, is known for his work with Borland on Turbo Pascal and Delphi (based on object-oriented Pascal). After leaving Borland, Hejlsberg worked at Microsoft on Visual J++.

Some aspects of C# will be familiar to those who have programmed in C, C++ , or Java. C# incorporates the Smalltalk concept, which means everything is an object. In other words, all types in C# are objects. C# properties are similar to Visual Basic properties. The Rapid Application Development (RAD) goal in C# is assisted by C#'s use of concepts and keywords, such as class, struct, statement, operator, and enum. The language also utilizes the concepts contained in the Component Object Model (COM) architecture.

Unlike Visual Basic or Delphi, events are data types in C# and can belong to an object. Members of a class object can have variables, methods, properties, and events. Attributes are another nice feature of the language.

Note: C# is a case-sensitive language.

C# and Open Source: The Mono Project

C# and Common Language Infrastructure (CLI) is under consideration at the European Computer Manufacturers Association (ECMA). You'll probably see C# running on Unix and Linux operating systems. It's no wonder you see many C# compilers emerging from different development tool companies.

Ximian, the Boston-based company that's well-known for its open-source product, GNOME, is working on a Linux-based, .NET open-source project called the Mono Project. The Mono Project incorporates key .NET-compliant components, including a C# compiler, a Common Language Runtime (CLR), a Just-In-Time (JIT) compiler, and a set of class libraries that will let developers create .NET applications that run on Windows, Linux, or Unix platforms. You'll find more information on the Mono Project at http://www.ximian.com/mono/ or at the ECMA Web site at http://www.ecma.ch./.

How and Why C# Came to Be

It was a dream of developers to have a language as powerful and as fast as C++, yet as easy to program as Microsoft's Visual Basic and Borland's Delphi. Microsoft planned its .NET Framework and C# language for years.

Prior to .NET, the most popular programming languages for Web and Windows development were Visual Basic, Java, Visual C++, and Delphi. Each of these languages has its pros and cons. Visual Basic and Delphi are easy to use and simple to program; however, they're not truly object-oriented, and they lack the flexibility to develop complex programs. Java is good for Web development, but it still lacks in its object-oriented aspects and in its capability to develop complex Windows applications. Java's platform independence, however, is a plus. Visual C++ is a great tool to develop Windows- and COM-based applications, but it's not as easy to use as Visual Basic or Delphi.

Microsoft wanted to develop an integrated tool with all the positive features of these languages and more. C# is the result. C# is as easy to use and as productive as Visual Basic and Delphi. Because it's derived from C and C++, it doesn't leave the C++ programmer at the beginning of the learning curve. C# also has the power and flexibility of C++. Because of its platform-independent nature (companies are still working on supporting C# on other operating systems such as Unix and Linux), you can deploy C# applications onto any .NET-supported platform. C# also provides Web development similar to Java with the help of ASP.NET.

Characteristics and Features of C#

As explained, C# was developed as a language that would combine the best features of previously existing Web and Windows programming languages. I'll discuss some of the primary characteristics of C# in the following sections.
Modern and Object Oriented
A modern language is one that provides latest features and tools for developing scalable, reliable, and robust industry-standard applications. C# is a modern language. The current trend in programming is Web development, and C# is the best language for developing Web applications and components for the Microsoft .NET platform.

As mentioned, C# is an object-oriented language. It supports all the basic object-oriented language features: encapsulation, polymorphism, and inheritance. Unlike C++, C# doesn't support multiple inheritance; however, there are always workarounds if you really need this capability. A few articles are available on C# Corner (http://www.c-sharpcorner.com/Language/MultipleInheritanceCB.asp) for more information on such workarounds.

Simple and Flexible
C# is as simple to use as Visual Basic, in that everything in C# is represented as an object. All data types and components in C# are objects. C++ programmers are sometimes confused when choosing different access operators to process objects. With C#, you use a dot (.) operator to access the object members.

Programmers use C# to develop both managed and unmanaged code. Managed code is code managed through the CLR module. It handles garbage collection, typesafety, and platform-independent behavior. Unmanaged code, on the other hand, is code run outside the CLR, such as an ActiveX control. C# provides the flexibility of using native Win 32 application programming interface (API) and unmanaged code through COM+. C# enables you to declare unsafe classes and members having pointers, COM interfaces, structures, and native APIs. Although the class and its members are not typesafe, they still can be executed from managed code using COM+. Using the N/Direct feature of C# and COM+, you can use the C language API. With the help of the COM+ run-time and the COM+ Common Language Specification (CLS), you can access the COM and COM+ API. Using the Sysimport attribute, you can even access native Windows API (DLLs) in C#. See the "Attributes" section of this chapter for more about attributes.

Typesafety
C# is a typesafe language. All variables and classes (including primitive types, such as integer, Boolean, and float) in C# are a type, and all types are derived from the object type. The object type provides basic functionality, such as string conversion, and information about a type. (See "The Object Class" section of this chapter for more about the object type). C# doesn't support unsafe type assignments. In other words, assigning a float variable directly to a Boolean variable is not permitted. If you assign a float type to a Boolean type, the compiler generates an error.

C# has two kinds of types: value types and reference types. All value types are initialized with a value of zero, and all reference types are automatically initialized with a null value (local variables need to be initialized explicitly or the compiler throws a warning). The "Types in C#" section of this chapter will discuss types in more detail.

Note: Some books and documentation also use the word type to mean a class such as MSDN.
Automatic Memory Management and Garbage Collection
Automatic memory management and garbage collection are two important features of C#. With C#, you don't need to allocate memory or release it. The garbage collection feature ensures that unused references are deleted and cleaned up in memory. You use the new operator to create a type object, but you never need to call a delete operator to destroy the object. If the garbage collector finds any unreferenced object hanging around in memory, it removes it for you. Although you can't call delete directly on an object, you have ways to get the garbage collector to destroy objects.
Versioning Control and Scalable
If you're a Microsoft Windows developer, you should be familiar with the expression DLL hell, which refers to having multiple versions of the same Dynamic Link Library (DLL) and not having backward and forward compatibility. For example, you can't run programs written in Microsoft Foundation Class (MFC) version 4.0 on systems with MFC version 3.0 or earlier. This is one of the biggest challenges for a developer, especially if you're developing MFC applications.

The C# model is based on namespaces. All interfaces and classes must be bundled under a namespace. A namespace has classes as its members. You can access all the members or just a single member of a namespace. Two separate namespaces can have the same class as their member.

C# also supports binary compatibility with a base class. Adding a new method to a base class won't cause any problems in your existing application.

.NET assemblies contain metadata called manifest. A manifest stores information about an assembly such as its version, locale, and signature. There is no concept of registry entries for handling compatibility. In .NET, you simply put your assembly into one global folder if you want to make it sharable; otherwise, you put it in a private folder for private use only.

Language and Cross-Platform Interoperability
C#, as with all Microsoft .NET-supported languages, shares a common .NET run-time library. The language compiler generates intermediate code, which a .NET-supported compiler can read with the help of the CLR. Therefore, you can use a C# assembly in VB .NET without any problem, and vice versa.

With the full support of COM+ and .NET Framework services, C# has the ability to run on cross-platform systems. The Web-based applications created from .NET use an Extensible Model Language (XML) model, which can run on multiple platforms....

Read More Show Less

Table of Contents

Foreword
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Ch. 1 Introduction to C# 1
Ch. 2 Introduction to Windows Forms 69
Ch. 3 Overview of ADO.NET 123
Ch. 4 Data Components in Visual Studio .NET 153
Ch. 5 ADO.NET Data Providers and Disconnected Classes 229
Ch. 6 Working with XML 355
Ch. 7 Developing Web Applications Using ADO.NET 435
Ch. 8 Using Web Services with ADO.NET 511
Ch. 9 Handling ADO.NET Events 545
Ch. 10 Different Flavors of ADO.NET 573
Ch. 11 Working with the ODBC .NET Data Provider 613
App. A Relational Databases: Some Basic Concepts 653
App. B Commonly Used SQL Statements 667
Index 685
Read More Show Less

Customer Reviews

Average Rating 4
( 4 )
Rating Distribution

5 Star

(2)

4 Star

(1)

3 Star

(0)

2 Star

(0)

1 Star

(1)
Sort by: Showing all of 4 Customer Reviews
  • Anonymous

    Posted Tue Oct 08 00:00:00 EDT 2002

    Perfect if you are moving to ADO.NET

    I start working with ASP.NET Web Services and Web Application and use MySQL as back end. I've seen couple of books but none of them provides good coverage on ODBC data provider. Author has done an exellent explaing database connectivity with various ODBC data sources. Good coverage of XML Services and intro to Web Applications. An above average book for ADO.NET, XML and Web database programmers. I agree with other reviewer that the author's style, which makes the book feel like a discussion with an enthusiastic co-worker rather than as a dry treatise. Normally you would think developing Web Services are a "BIG DEAL" but author explained in a way which makes Web services a "Peice of Cake". Based on this book, I wrote a Web service, which works as a Database Layer for my three ASP.NET applications to send data back and forth.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted Mon May 27 00:00:00 EDT 2002

    Seriously poor book

    I have the greatest respect for APress and the many .NET titles they have published. I especially like Troelsens books and I was hoping this was another excellent title from APress. However, I have to say that this book is a disappointment from page one. There are so many minor mistakes in the book and towards the end it becomes worse. The author doesn't know the subject well enough to be writing a book like this. APress do yourself a favor, drop this book and make sure the author is kept on a leash in the future or simple rop him too!

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted Fri Jun 07 00:00:00 EDT 2002

    Over all good book to start ADO.NET

    Nothing more to add over all good book for ADO.NET (basics)

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted Tue Apr 16 00:00:00 EDT 2002

    Little different... Enjoying it

    I preordered this item two months ago and just got my hands on this book. Today I finished two chapters (Chapter 3 and 4). Chapter 1 and 2 are C# and Windows Programming so I skipped them. I found this book little different than the other book I have. It's not a copy of MSDN documentation. I like author's approach of discussing ADO.NET architecture and its component visually. It clears my basics about ADO.NET components and how they fit together. Any way, I'll read more and write comments in more details in a week of so. So far enjoying it. Too bad I don't see VB.NET code in it but conversion from C# to VB.NET is not a big deal. Cheers!

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 4 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)