Connecting to a Database

To start, the first thing we'll look at is how to interact with a database in .NET. The .NET Framework has a rich set of classes for managing and working with databases.These classes are collectively referred to as ADO.NET. ADO.NET is very similar to, and evolved from, its predecessor ADO.The key difference between the two is that ADO.NET has a disconnected data architecture. This means that when you receive the data from the database, the result is stored on your local machine.You can then...

Event Handling in Java

In Java's AWT, events are usually handled through inner classes that implement the ActionListener interface. Let's look at an example. Figure 8.1 defines a JPanel object. It will use an inner class that implements ActionListener as an event handler. This will be added as a handler for a button click event. Figure 8.1 Java JPanel Object with Event Handling public class MyPanel extends JPanel Here is a button to receive click events. JButton myButton new JButton(Click me) And now for an inner...

The NET Philosophy

Overview of the .NET Platform Examining the .NET Framework Features Understanding the .NET Architecture Following .NET Code from Source to Binary 0 Summary 0 Solutions Fast Track 0 Frequently Asked Questions Before we start our journey into the C language, let's step back and look at the bigger picture. C is a key part of Microsoft's new .NET initiative.The Redmond view of .NET is that is provides a development platform for the Internet, while at the same time providing new application...

Creating a Simple Visual J Application

We will now build a very simple Visual J application that is meant solely to give you an idea of what a Visual J application looks like.You are encouraged to change and manipulate its graphical user interface and methods to build code that is of some practical use to you, or to improve upon the code. The Visual J application we're going to build is an image previewer program that displays Bitmap images from a specified directory. Figure 15.5 shows the graphical user interface (GUI) for the...

Differences between HTML and Web Controls

Web Forms exist in two types that differ in functionality HTML controls and Web controls. Both of these controls render the output in HTML for a Web browser. They also encapsulate the mechanisms for preserving state across server round-trips and for invoking server-side events that are handled on the server. Let's look at some of the key differences between the two types of controls. 1. Web controls provide a richer functionality than the HTML controls. HTML controls basically are rendered HTML...

Web Service Description Language

We need a blueprint or a software contract specification to create our proxy object.This contract specification is referred as a Web Service Description Language file. The WSDL describes the Web Service implementation details to the proxy objects. You can obtain the contract of a .NET Web Service by appending WSDL to the URL of the Web service you're trying to access. In our previous example the URL will look similar to this. You can also click the Service Description link in the .asmx file.The...

Using the ActiveX Control Importer Utility AxImpexe

The Microsoft .NET Framework comes with a set of command line utilities one of them is the AxImp.exe utility.You can use this utility to create a wrapper class for any ActiveX control that you can use under the Windows Forms environment.The wrapper control is derived from the class called System.Windows.Forms.AxHost.This wrapper class will act as a proxy between the ActiveX control and .Net runtime. The following is the syntax for using the utility Aximp.exe options file.dll file.ocx The...

Creating the Media Player Application

The first thing we need to do is create an eye-catching graphical user interface for our media player.The GUI for our application will be fairly simple it will contain only a menu where a user can open a file dialog and select a song or movie. To do this, we need to create a Windows Form that will anchor the rest of our components.The process is similar to creating a Swing or AWT application in Java, where first you create a JFrame and then add components to it. The code for creating the...

Verbatim String Literal

C also adds a new form of literal, dubbed the Verbatim String Literal, which permits creating string literals exactly as written. Rather than interpreting the character as the start of an escape sequence, it interprets it verbatim.To indicate that a string literal is a Verbatim String Literal, precede it with the character. Keep in mind that to represent a double quote you must use two double quote characters.The following two declarations are equivalent String stringLiteral C C programs String...

If elif else and endif

The if elf else, and endif preprocessor directives are all used for conditional processing when your program is compiled.The f and elif both evaluate the symbols to determine whether they are defined or undefined. The else preprocessor directive allows for a compound conditional directive to be created. And finally, the endif preprocessor directive specifies the end of a conditional directive. Now for a little more detail on how these work.You can think of these directives as a typical if else...

Jlb

BufferedStream bin new BufferedStream file BinaryReader din new BinaryReader bln It would be impossible to sandwich BinaryReader in the middle layer of these streams. In this respect, the C API has just a little more enforcement than the Java API. Table 11.7 shows the methods in BinaryReader and the corresponding methods in Java. Notice the method names for integers and floating point numbers seem quite general. For example, C uses ReadInt16 rather than ReadShort .This is because these classes...

Building a Web Service

Declaring your class as a Web service and having certain methods exposed and executed over the Web is fairly easy. In .NET, a Web service is as an ASP.NET file with an .asmx file extension.These files will contain the class and methods of an XML Web service.You can easily expose your program as a Web service by adding several lines and saving it as an .asmx file. For our example, we'll turn our Book_Details class into an XML Web service by exposing the GetBookTitleByID method as a Web method....

Frequently Asked Questions

The following Frequently Asked Questions, answered by the authors of this book, are designed to both measure your understanding of the concepts presented in this chapter and to assist you with real-life implementation of these concepts. To have your questions about this chapter answered by the author, browse to www.syngress.com solutions and click on the Ask the Author form. Q How do I define global constants in C A It is common practice to create a class with nothing but constant members....

Windows Form Class Hierarchy

The System.Windows.Forms namespace also known as the WinForms namespace provides the necessary classes for implementing forms and the various controls that can be placed onto these forms. Figure 12.1 shows some of the major classes within the Windows Form class hierarchy. Figure 12.1 Windows Form Class Hierarchy As you can see, this is very similar to Java's AWT Swing hierarchy where similar objects are derived fromjava.lang.Object.The Form class in C is similar to the Applet class in Java,...