Friday 1 April 2016

ADO.NET :: Classes for holding data

Classes for holding data


The following are the main classes used to hold data in Ado.NET:
  • DataSet
  • DataTable
  • DataRow


  • A DataSet is an in-memory representation of the database.
  • DataSet contains DataTables (and more...)
  • DataTable represents a database table
  • DataTable contains DataRows (and more...)
  • A DataRow represents a record in a database table.
  • DataRow is a collection of all fields in a record.

We can use the DataAdapter or DataReader to populate data in DataSet. Once we populate data from database, we can loop through all Tables in the DataSet and through each record in each Table.

On the first look, this may look bit confusing, but once you understand the concept and get familiar with the Ado.NET classes, you will appreciate the power and flexibility of Ado.NET.
Read More »

ADO.NET :: Classes for communicating with database

Classes for communicating with database



The Connection, Command, DataReader, and DataAdapter
objects are the core elements of the ADO.NET provider model.


Object
Description
SqlClient Objects
OleDb Objects
Connection
Establishes a connection to a specific data source.
SqlConnection
OleDbConnection
Command
Executes a command against a data source.
SqlCommand
OleDbCommand
DataReader
Reads a forward-only, read-only stream of data from a data source.
SqlDataReader
OleDbDataReader
DataAdapter
Populates a DataSet and resolves updates with the data source.
SqlDataAdapter
OleDbDataAdapter

Each provider may have classes equivalent to above objects. The name of the classes vary slightly to represent the provider type appropriately.

Depending on the type of database you work on, you will have to choose either OleDb or SqlClient (or, some other provider) objects. Since all our samples use MS Access database, we will be using OleDb objects in all the samples. If you like to use SqlServer, you just need to replace the OleDb objects with the equivalent SqlClient objects.
Read More »

ADO.NET :: ADO.NET and DataAccess Providers in .NET

ADO.NET

ADO.NET is the data access model that comes with the .NET Framework. ADO.NET provides the classes required to communicate with any database source (including Oracle, Sybase, Microsoft Access, Xml, and even text files).

DataAccess Providers in .NET

ADO.NET comes with few providers, including:

  • OleDb
  • SqlClient

There are other providers available, but we are not including them here as this tutorial is meant for beginners! When you want them, search for ADO.NET providers in Google or MSDN Microsoft made the SQL Server. So they gave a separate provider, specifically made for SQL Server. We can use the OleDb provider for all other database sources including MS Access, Oracle, Sybase etc. There is a separate provider available for Oracle.

A DATA PROVIDER is a set of classes that can be used to access, retrieve and manipulate data from the databases.

Both OleDb and SqlClient has its own set of classes, but they have the same concepts. We would like to classify the classes into two broad categories (this is not a microsoft classification, anyway!)

  • Classes for communicate with database
  • Classes for holding/manipulating data

The job of first category of classes is to communicate with database and send or retrieve data from the database. The second category of the classes will be used as a carrier of data.
Read More »

ADO.NET :: Database Concepts

Database Concepts

Database is the media to store data. If you have an application that has to store and retrieve data, your application must be using a database.

A File is the simplest form of saving the data in the disk, but is not the most efficient way of managing application data. A database is basically a collection of one or more files, but in a custom format, and data is organized in a specific format such a way that it can be retrieved and stored very efficiently.

Some examples for databases are :

  • MS Access
  • SQL Server
  • Oracle

MS Access is a very light weight database provided by Microsoft for applications with less number of users and relatively small quantity of data. MS Access saves data into database files with the extension .mdb. Usually, MS Access comes along with MS Office package. If you already have the .mdb database file, you can freely use it with your application and you do not need MS Access software. The MS Access software is required only if you want to directly open the database and manipulate the data or change the database schema.

SQL Server (Microsoft product) and Oracle (Oracle Corp.) are more complex, advanced, relational databases and they are much more expensive. It can support large number of users and very high quantity of data. If you are developing a software, which might be accessed simultaneously by 100s of users or if you expect your data may grow 100s of MBs, you might consider one of these. (We are learning Microsoft .NET.. so you might want to consider the SQL Server than Oracle, for which Microsoft provides special data access components!!)

In this tutorial, we will be using only MS Access for simplicity. Most of the samples provided in this site uses MS Access database for simplicity and easy download.
Read More »

ADO.NET for Beginners

ADO.NET for Beginners


Accessing Database


Accessing database using ADO.NET in C# or VB.NET This tutorial will teach you Database concepts and ADO.NET in a very simple and easy-to-understand manner with many code snippets and samples. This is primarily meant for beginners and if you are looking for any advanced ADO.NET topics, this may not be the right page for you.

Topic Covered:


Read More »

Thursday 31 March 2016

How to Get File Name without Extension?

Here we discuss about how to get current page title name?

When we use below code:


    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Page.Title))
        {
            string path = Path.GetFileName(Request.Path);            
        }
    } 

Example:


Read More »

Wednesday 30 March 2016

How to add a favicon images to your asp.net page?

How to add a favicon images  to your asp.net page? 

How can you add images to your asp.net title page?



Step 1: Firstly convert your logo or image to favicon.ico. 
This can be done as follows:

  • Go to the link given below,
http://favicon-generator.org/
  • Choose your image, convert it to .ico.
  • Download your favicon.ico to your application directory.


Step 2: Copy and paste this favicon.ico to image folder of project.
Step 3: Open Master page(SiteMaster).
Step 4: Copy the below generated code to the head tag of your page:

<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/favicon.ico" type="image/icon" />

Now, this will display your title icon the way u want.
Read More »

Wednesday 3 February 2016

Object Oriented Paradigm

1.4 Object Oriented Paradigm

The major motivating factor in the invention of object-oriented approach is to remove some of the flaws encountered in the procedural approach. OOP treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the function that operate on it, and protects it from accidental modification from outside function. OOP allows decomposition of a problem into a number of entities called objects and then builds data and function around these objects. The organization of data and function in object-oriented programs is shown in fig.1.3. The data of an object can be accessed only by the function associated with that object. However, function of one object can access the function of other objects.


 

Some of the features of object oriented programming are:
  • Emphasis is on data rather than procedure.
  • Programs are divided into what are known as objects.
  • Data structures are designed such that they characterize the objects.
  • Functions that operate on the data of an object are ties together in the data structure.
  • Data is hidden and cannot be accessed by external function.
  • Objects may communicate with each other through function.
  • New data and functions can be easily added whenever necessary.
  • Follows bottom up approach in program design.
Object-oriented programming is the most recent concept among programming paradigms and still means different things to different people.
Read More »

Procedure-Oriented Programming

 

1.3 Procedure-Oriented Programming

In this approach, the problem is viewed as the sequence of things to be done such as reading, calculating and printing such as cobol, fortran and c. The primary focus is on functions. A typical structure for procedural programming is shown in fig.1.2. The technique of hierarchical decomposition has been used to specify the tasks to be completed for solving a problem.


 

Procedure oriented programming(POP) basically consists of writing a list of instructions for the computer to follow, and organizing these instructions into groups known as functions. We normally use flowcharts to organize these actions and represent the flow of control from one action to another.

In a multi-function program, many important data items are placed as global so that they may be accessed by all the functions. Each function may have its own local data. Global data are more vulnerable to an inadvertent change by a function. In a large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure, we also need to revise all functions that access the data. This provides an opportunity for bugs to creep in.


Another serious drawback with the procedural approach is that we do not model real world problems very well. This is because functions are action-oriented and do not really corresponding to the element of the problem.

 
Some Characteristics exhibited by procedure-oriented programming are:

  • Emphasis is on doing things (algorithms).
  • Large programs are divided into smaller programs known as functions.
  • Most of the functions share global data.
  • Data move openly around the system from function to function.
  • Functions transform data from one form to another.
  • Employs top-down approach in program design.
Read More »

Thursday 28 January 2016

Procedure-Oriented Programming

1.3 Procedure-Oriented Programming


In the procedure oriented approach, the problem is viewed as the sequence of things to be done such as reading, calculating and printing such as cobol, fortran and c. The primary focus is on functions. A typical structure for procedural programming is shown in fig.1.2. The technique of hierarchical decomposition has been used to specify the tasks to be completed for solving a problem.


Procedure oriented programming basically consists of writing a list of instructions for the computer to follow, and organizing these instructions into groups known as functions. We normally use flowcharts to organize these actions and represent the flow of control from one action to another.
 
In a multi-function program, many important data items are placed as global so that they may be accessed by all the functions. Each function may have its own local data. Global data are more vulnerable to an inadvertent change by a function. In a large program it is very difficult to identify what data is used by which function. In case we need to revise an external data structure, we also need to revise all functions that access the data. This provides an opportunity for bugs to creep in.
 
Another serious drawback with the procedural approach is that we do not model real world problems very well. This is because functions are action-oriented and do not really corresponding to the element of the problem.
 
Some Characteristics exhibited by procedure-oriented programming are:
  •  Emphasis is on doing things (algorithms).
  •  Large programs are divided into smaller programs known as functions.
  •  Most of the functions share global data.
  •  Data move openly around the system from function to function.
  •  Functions transform data from one form to another.
  •  Employs top-down approach in program design.

Read More »