Skip to main content

Posts

datatable compute sum in c# | datatable compute() function

datatable compute sum in c# | datatable compute() function Hi Readers, Today I am going to explain you the use of compute() function of Data table using C#.NET .  Let's begin.. datatable column sum in c# datatable compute sum in c# | datatable compute() function Let's say that we have the following rows filled in the Data table with the columns ID,NAME,AGE and SALARY as shown in snapshot below:- employees detail in datatable In order to calculate the figures like total of salary, average of salary, maximum salary and minimum salary, we can use the compute() function of the Data table. The compute() function loops through each value of the column's cell and then perform the calculation. For the above data table's salary column, lets find the total, average, maximum and minimum of salary one by one using compute() function:- datatable compute sum in c# | datatable compute() function Calculate the total of sala
Recent posts

Adding rows to Datatable using C#.NET

Adding rows to Datatable using C#.NET Hi Readers, Today I am going to explain you 2 ways that we can use to add rows to a Data table using C#.NET.  So lets begin: Add row in datatable in c# Adding rows to Datatable using C#.NET > Lets say, we have a data table with the columns ID, NAME, AGE AND SALARY and I want to add rows to this data table using C# coding . > First of all, add columns to data table using the following lines of code: DataTable dtEmployee = new DataTable("Employee"); dtEmployee.Columns.Add("ID", typeof(int)); dtEmployee.Columns.Add("NAME", typeof(String)); dtEmployee.Columns.Add("AGE", typeof(int)); dtEmployee.Columns.Add("SALARY", typeof(Decimal)); Add row in datatable in c# > Now if we want to add rows to the above data table at run time, we have the following 2 ways to do so: Adding rows to Datatable using C#.NET 1. Using DataRows :- In this, we create an o

C# Dictionary

> In this post, we will see how to use a dictionary in C#. > A dictionary in C# is used to store collection of values with key values as pair. > So whenever user wants to get the value then he will have to pass the key value to the dictionary and it will return the value to the user. > The namespace of the C# dictionary is System.Collections.Generic. > Let’s take a simple example of storing digits from 0 to 9 as key value and these digits in the word form as the collection values. > Here, the user will type a digit from 0 to 9 and on clicking the button, it gives the digit in the word form. > To keep this example simple, here the dictionary will be having digits from 0 to 9 only and if user enters a value less than 0 or greater than 9 then he will get the appropriate message. > Following is the code for demonstrating the use of the Dictionary : HTML Code: <body>    <form id="form1" runat="server">        <

Things to know if you are a web developer or want to be

Following are some of the basic points to know: WHAT YOU SHOULD KNOW TO BECOME A .NET WEB DEVELOPER?            > HTML(Hyper Text Markup Language).           > Client Side Scripting language like JavaScript or VBScript or library like jQuery.           > Programming languages like C#,VB(Visual Basic),C++.           > Database query language like SQL(Structure Query Language),Oracle etc.           > CSS (Cascading Style Sheet) to make web pages look interactive. WHAT IS A WEB SERVER > A web server is  a program which serves web pages to the web users. > The web user uses the application called 'Browser' (e.g. Google Chrome, Mozilla Firefox, Opera Mini etc.) to view the served web pages. > The web server can be either a program or a system. > The system in which a web server runs is also called a 'web server'. > Examples of web server are IIS (Internet

.config files

> To store the connection strings at a place, configuration files are used in .net application.  > We use web.config file for web application and app.config file for windows application. WEB.CONFIG:- •          It’s a configuration file for web application. •          This file is used to store the connection string which contains the code for the connectivity with the data source. •          This file is added by default if we are developing ASP.NET web application. •          The extension of a configuration file is .config . •          A configuration file can store multiple connectionStrings .         APP.CONFIG:- •          It’s a configuration file for windows application. •          This file is also used to store the connection strings which contains the code for the connectivity with the data source. •          This file has to be added explicitly as it is not added by default. •          The extension of this configuratio

ConfigurationManager Class

•          The ConfigurationManager class is used to read the connectionString from the configuration file. •          This class is present in the Configuration namespace. •          The assembly reference of this class is added by default for web application. •          But for windows application,we need to add assembly reference explicitly. •          To add reference in windows application project in visual studio:- •          Go to solution explorer. •          Right-Click on the references section. •          Select the Add Reference option from the menu. •          Select the System.Configuration from the dialog box and click OK. •          The assembly reference is now added for the ConfigurationManager class in windows application. That's it....Thanks for reading this post.

ConnectionStrings

•     While developing any application that has to interact with the data source in order to retrieve,insert,update and delete the data from it, there are possibilities that a developer can make mistakes while establishing connection to the data source by hard coding the ConnectionString in the source code. •        Hard coding such lines of code for an application consumes time and requires man power to make an application work perfectly if the application has many web pages or windows forms. •          The developer has to connect the application to different data source in order to test it. In such situation, hard coding may lead to errors in the source code because we need to make changes for every ConnectionStrings in all web pages/windows forms for a single data source which is definitely error prone and time consuming. •       So to overcome such situation, we have ConnectionStrings class where we place the code of the connection and give that connection; a meanin