Monday, 5 March 2018

Visual Studio IDE

Setup windows forms application in c#

Download the following pdf file for the steps to create setup files
https://drive.google.com/file/d/1DiSyZy-QwVM8Pygle1Yx-7slcgxh3r9h/view?usp=sharing

Collection in C#

Reference Link:
1. http://www.tutorialsteacher.com/csharp/csharp-collection
2. http://www.c-sharpcorner.com/UploadFile/736bf5/collection-in-C-Sharp/
3.https://www.tutorialspoint.com/csharp/csharp_collections.htm 
Non-generic Collections Usage
ArrayList ArrayList stores objects of any type like an array. However, there is no need to specify the size of the ArrayList like with an array as it grows automatically.
SortedList SortedList stores key and value pairs. It automatically arranges elements in ascending order of key by default. C# includes both, generic and non-generic SortedList collection.
Stack Stack stores the values in LIFO style (Last In First Out). It provides a Push() method to add a value and Pop() & Peek() methods to retrieve values. C# includes both, generic and non-generic Stack.
Queue Queue stores the values in FIFO style (First In First Out). It keeps the order in which the values were added. It provides an Enqueue() method to add values and a Dequeue() method to retrieve values from the collection. C# includes generic and non-generic Queue.
Hashtable Hashtable stores key and value pairs. It retrieves the values by comparing the hash value of the keys.
BitArray BitArray manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).


For more details click on the link that is given in the table.
Also download the file for more information:
https://drive.google.com/file/d/1ZgkfZpeil3tXdccLpbFE2HjZmfgnjypK/view?usp=sharing




































COMPONENTS OF CONNECTED AND DISCONNECTED ARCHITECTURE IN C#

Reference Link: http://www.c-sharpcorner.com/UploadFile/8a67c0/connected-vs-disconnected-architecture-in-C-Sharp/
You can use two C# objects to achieve this, first one is DataSet and other one is DataReader.

DataSet

DataSet

It is a type of disconnected architecture. Disconnected architecture means, you don’t need to connect always when you want to get data from the database. You can get data from dataset; basically DataSet is a collection of datatables. We can store the database table, view data in the DataSet and can also store the xml value in dataset and get it if required.

To achieve this you need to use DataAdapter which work as a mediator between Database and DataSet.

Example


public DataSet GetEmployeeData()
{
    SqlConnection conString = new SqlConnection("myconnection");
    conString.Open();
    SqlCommand cmdQuery = new SqlCommand("Select * from Employee", conString);
    SqlDataAdapter sda = new SqlDataAdapter(cmdQuery);
    DataSet dsData = new DataSet();
    sda.Fill(dsData);
    return dsData;
}  
DataReader

It is a connected architecture, which means when you require  data from the database you need to connect with database and fetch the data from there. You can use if you need updated data from the database in a faster manner. DataReader is Read/Forward only that means we can only get the data using this but we cannot update or insert the data into the database. It fetches the record one by one.

Example
static void HasRows(SqlConnection connection)
{
    using (connection)
    {
        SqlCommand command = new SqlCommand("SELECT CategoryID, CategoryName FROM Categories;",connection);
        connection.Open();
        SqlDataReader reader = command.ExecuteReader();
        if (reader.HasRows)
        {
            while (reader.Read())
            {
                Console.WriteLine("{0}\t{1}", reader.GetInt32(0),reader.GetString(1));
            }
        }
        else
        {
            Console.WriteLine("No rows found.");
        }
        reader.Close(); 
    }

For more details download the following PDF file
https://drive.google.com/file/d/1kuDA7y7MmQcvE9W5vq6bdN-_CRsNVD5R/view?usp=sharing
 

Connected and disconnected architecture in C#

Connected and Disconnected architecture in C#

Connected Architecture of ADO.NET
The architecture of ADO.net, in which connection must be opened to access the data retrieved from database is called as connected architecture. Connected architecture was built on the classes connection, command, datareader and transaction. 
Connected architecture is when you constantly make trips to the database for any CRUD (Create, Read, Update and Delete) operation you wish to do. This creates more traffic to the database but is normally much faster as you should be doing smaller transactions.
Disconnected Architecture in ADO.NET

The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture. Disconnected architecture of ADO.net was built on classes connection, dataadapter, commandbuilder and dataset and dataview.
Disconnected architecture is a method of retrieving a record set from the database and storing it giving you the ability to do many CRUD (Create, Read, Update and Delete) operations on the data in memory, then it can be re-synchronized with the database when reconnecting. A method of using disconnected architecture is using a Dataset.

DataReader is Connected Architecture since it keeps the connection open until all rows are fetched one by one
DataSet is DisConnected Architecture since all the records are brought at once and there is no need to keep the connection alive
Difference between Connected and disconnected architecture

Connected Disconnected
It is connection oriented.
It is dis_connection oriented.
Datareader DataSet
Connected methods gives faster performance
Disconnected get low in speed and performance.
connected can hold the data of single table disconnected can hold multiple tables of data
connected you need to use a read only forward only data reader
disconnected you cannot
Data Reader can't persist the data
Data Set can persist the data
It is Read only, we can't update the data.
We can update data

Create crystal report step by step in c-sharp

The following is the hyperlink to create the crystal report step by step in c#:
Step by step to create crystal report in c#

Sections

Sections are the design areas which you use to build your report.
Crystal Reports by default provides five main sections:

  • Report Header – fields placed in this section are printed once, at the beginning of the report
  • Page Header - fields placed in this section are printed at the beginning of each new page
  • Details – fields in this section are printed with each new record
  • Report Footer - fields placed in this section are printed once, at the end of the report
  • Page Footer - fields placed in this section are printed at the bottom of each new page