Programming Examples

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


Articles on C# programming language.

Understanding & Using AppConfig File

AppConfig File C# Example

Let us say we are writing an Internet modem device monitor service application. The duty of the application will be tracking for Upload and download action of the modem. When there is a large download say 500KB per second for past 10 Minutes, the device should assert that to a user. The intimation can be done either by blinking a Red LED in the modem device or by making continues beep or by making the entire desktop with a red transparent overlay. But which option the utility should choose from? Now I hear you are saying keep it as an ‘Application Setting’. In C#, it is AppConfig file.

In old days, Legacy windows desktop software uses section-based Initialization Config Files (‘INI Files’) and App reads and writes from it. The coder places the settings on sections, which are nothing but organizing the settings under a certain group. Now in dot net days, Microsoft replaced the INI files as AppConfig files. They place the App settings in the XML format in application config files aka AppConfig file. In this article, we will explore how to make use of the AppConfig file. For exploring, we will create a simple C# Windows Form based example.

Continue Reading →

Hooking CustomValidator Control & Javascript

CustomValidator & Java-script Scripting

Validation controls are useful to perform the validation on the web forms. The framework provides validation controls like RequiredFieldValidator, RangeValidator and CompareValidator, etc. Sometimes, these validation controls are not fair to do the special validations. In those cases, we will go for the CustomValidator Control. In this example we will walk through the usage of the CustomValidator Control and learn how to link the java script function as the validation function.

Continue Reading →

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 →