Programming Examples

Are you a Programmer or Application Developer or a DBA? Take a cup of coffee, sit back and spend few minutes here :)

Ado.Net SqlCommand Example

ExecuteReader ExecuteNonQuery ExecuteScalar Block Diagram

To fetch data from the database, we need DB connection. In ADO.Net, based on the Database Provider, there are distinct connection classes. For example, to hook up to an Oracle Database we need to use OracleConnection and in the same way we need SqlConnection to hook up to the SQL Server database. The Command Object is also database specific. For Example, SqlCommand object can talk with SQL Server DB through SqlConnection object and OracleCommand object can talks to the Oracle DB through OracleConnection. These command objects know what needs to be executed in the database. In this article, we will study how to use SqlCommand and its methods ExecuteScalar, ExecuteReader and ExecuteNonQuery.

Continue Reading →

C# Owner Drawn ComboBox Example

Owner Drawn ComboBox Example

The control drawing itself is a normal behavior. Now, let us say that the Form draws each ComboBox item with a double lined red border around each item. Here, the Form is called a Parent or Owner of the ComboBox and the control is known as ‘Owner Drawn Control’. In easy words, the Form (Owner of the ComboBox) draws the ComboBox Items. In this article, we will see how to create an Owner Drawn ComboBox with color titles along with text.

Continue Reading →

FormView Control & SQLDataSource in ASP.Net

About The FormView Control Example

In this example, we will see how to make use of FormView Control of ‘Asp.Net to retrieve the data from the database. We will use SQLDataSource Control to supply the data for it. We will also look at modifying its Templates. This Control allows us to place the data-bound controls wherever we want. It is just like designing the form for calculating the Electricity Bill based on unit consumption. Now think of getting the table columns from the database and placing that freely on the web page wherever we want. This is achieved by the FormView Control.

Continue Reading →

Drawing Shapes Via GDI+ Brushes and Pens

DotNet GDI Plus Pen and Brush Example

A ‘Pen’ is a graphic object, which can be used to perform line drawing. GDI Pen has the properties like the color of the Pen and thickness of the pen. A Brush is also a graphic object, which we can use to paint a region. Suppose if we want to fill the area of a closed shape, we can use the Brush. One can think about Painting a door, a wooden plate, etc. In this example, we will explore how to use the ‘Pen’ and ‘Brush’. In the brush part, we will look at ‘Plain Solid Brush’, ‘Gradient Brush’ and ‘Hatch brush’.

In this example, we will explore about the GDI+ Pen and Brushes and use them to draw some shapes in the window’s form.

Continue Reading →