Here I have discussed about how to get all the dates of any Dayofweek in a year. Below is the stpes to caluclate all Dayofweek in a year. 1. Initialize a Collection for adding all Sundays in that. Collection<DateTime> listOfSundays = new Collection<DateTime>() 2. For that first we get the start date of the year as follows: DateTime startDate = new DateTime(year, 1, 1); 3. Now...
What is Fibonacci series? Sequence is set of objects (numbers) which are in Orders. Fibonacci series is a sequence of list of numbers which is invented by Leonardo Fibonacci (fi-bo-na-chee) in 1202; on the name of Leonardo Fibonacci it is named “Fibonacci series”. Fibonacci series are: 0,1,1,2,3,5,8,13,21,34,55……… In Fibonacci series first two numbers are 0 and 1 after that each subseque...
Literal Control: It is used to display data; it is lightweight and does not make any formatting techniques. Literal control will render only its text which is assigned in its text property. For example: < div > < asp : Literal ID ="Literal1" runat ="server" Text ="This is a literal control"> </ asp : Literal > </ div > this code render as: < div > This is a ...
Download Sample Project Many times we want to find out the next business (working) date after “N” business days. In this blog I have described how to find out the next business date after “N” business days. Here “N” is the number of business days. Business days means remove all the Sunday and Saturday which falls between “N” business days from the current date(Or from specified date). Be...
Leap year a year which have the 1 extra day from normal year, in leap year February have 29 days, in normal February have 28 day. Leap year has 366 days but normal year have 365. To find the given year is the leap year, for that the algorithm is: 1. Year should be completely divided by 4 i.e. reminder should be zero. 2. AND, Year should not be completely divided by 100 i.e. reminder shou...
In this blog I have discussed about how to Drop all the user defined table from the database OR Select/Delete/Truncate data from all the database tables OR alter the entire database table in one command. In SQL Server there is a system defined Procedure to perform Select, Delete, Truncate, Drop, Alter command on the entire database table in one shot command, the name of the procedure is:...
Barcode is a machine readable representation of data, which contains the data information. Basically barcode contains data information in parallel line. The most popular of barcode used font is “3 of 9” also known a code 39. Download Font Download barcode from above link and exact these in a folder after that just copy and paste font on the following location Control Panel >> Font....
Here I have discussed find the maximum value from enum. Suppose we have an enum like: public enum TestEnum { A=1, X=2, E=3, R=4, O=5 } if our enum have values like above(Incremented by one),then we can Find the Max enum values like as follows: String strMaxEnumValue = Enum .GetValues( typeof ( TestEnum )).Cast< TestEnum >().Last().ToString(); It returns last element of the sequence...
PagedDataSource is a class which encapsulates the paging related properties which is required to perform paging in data bound control like Repeater/DataList. PagedDataSource class comes under System.Web.UI.WebControls namespace. PagedDataSource contains following common properties: PageSize: It Defines number of records shown on the page. it’s default value is 10. AllowPaging: Indicating...
Here I am discussing to find date after a given week or months. For example I want to find the date after 1 week or 2 months from today. Find date after 2 week or 2 months then we can achieved this as like: DateTime dateTime = DateTime.Now.AddDays(14); //we can also do this as DateTime.Now.AddDays(2*7) DateTime dateTime1 = DateTime.Now.AddMonths(2); The output will be: 11/18/2009 3:59:43...
Here I have discuses find name of Enum from Enum value. I have a Enum like: public enum EnumName { Vijendra=1, Singh=2, Shakya=3 } I have the value of this Enum in my database table, when I fetch that value from database then we want to show this value as Enum name. For example in my database there is 2 when I retrieve it from database then I want to show it “Singh” instead o...
Here I have discussed how we auto refresh page and why we need to auto refresh the page. Page is Auto refresh means forcing a page to post back without user input. Following are the main reason to auto refresh the page. 1. Redirecting to a new URL after some specific time. 2. Refreshing page information within a given time period. 3. Maintain a session state. We auto refresh the page in ...
Many times we want to bind the Repeater with ArrayList.We can use Data Source property of Repeater for binding with Array List. Following is HTML page code: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Bind Repeater With ArrayList" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1...
In SQL many times we have null values and we wants return another value, for that purpose in SQL there is two methods: 1. COALESCE() 2. ISNULL() COALESCE() : It is ANSI standard function, and takes 2 or more number of parameters and each value can be of different datatype. It returns the first non-null parameter value in a list of parameter values. In COALESCE () all parameter can’t be n...
To execute the SQL Query or Storeprocedure, we use the SqlCommand object. We use the SqlCommand object as follows: // create the SqlCommand object String sqlQuery=”Select * from User”; SqlCommand cmd = new SqlCommand (sqlQuery, con); another way is: SqlCommand cmd = new SqlCommand (); cmd.CommandText = "SELECT Count(*) from users"; cmd.Connection = con; cmd.CommandType = CommandType.Text...
Many times there is needed to change the column name of table. So, we can change the column name of the table as follow: Sp_Rename 'TableName.OldColumnName','NewColumnName','Column' Here Column is the keyword. Hope it will help to all…
This is most popular question for the interview. Here I will discuss how to find nth highest salary. Consider we have a User table the column name of the user table are UserName, Salary, City ,Suppose inthis table we have following data UserName Salary City Vijendra 5000 Delhi Vijay 7200 Noida Vimlesh 4000 Agra Vikas 2700 Lucknow Vimal 3700 Noida Now we find the 3rd highest salary from t...
Many times we want to know How many Tables we using in our Database. Here I have written the query to find the total number of tables/columns used in Database. SELECT COUNT(*) FROM SYSOBJECTS WHERE XTYPE = 'U' Here U is used for Tables. This Query return TotalNumber of Tables present in the Database. If We want to Know the total column name in whole Database then used following Query SEL...
A cookie is a small bit of text file that browser creates and stores on your machine (hard drive). Cookie is a small piece of information stored as a string. Web server sends the cookie and browser stores it, next time server returns that cookie.Cookies are mostly used to store the information about the user. Cookies are stores on the client side. How to create the cookies: //for store t...
Asp.net provides Session for storing data that is unique for the individual user. Session is stores on the server side. Storing data in session: //Storing first Name in Session like: Session ["firstName "] = txtFirstName.Text; Retrieve data from session: first check the session is variable is null or not. if (Session["firstName "] != null) { //Retrieving firstName from Session litWelcome...
Truncate: Truncate is DDL (Data definition language) command. We can’t use where clause with truncate command. Once table is truncate we can’t rollback the data because it released the data from the memory. Truncate is faster than Delete because we can’t rollback the data in truncate and we can’t use the where clause. Truncate resets identity of the table. Syntax: Truncate table TableNam...
We use AND & OR operator in SQL when Where clause requeries more than one conditions. IN SQL, AND clause is used when we apply more than one condition with WHERE clause, and it gives the results when all given contions are true i.e all conditions to be true. Following is the Structure of the table: Create Table users ( FirstName varchar(50), City varchar(50) ) Insert into users (Firs...
The SQL DISTINCT keyword specifies that only distinct / non-duplicate results are to be returned and used together with the SQL SELECT keyword. We can apply DISTINCT on a single columns or to multiple columns. Create Table users ( FirstName varchar(50), City varchar(50) ) Insert into users (FirstName,City) values(null,'Noida') Insert into users (FirstName,City) values('vijendra','Delhi')...
SQL Count() function returns number of Rows in a certain table. Count() is an aggregate function(aggregate function returns a single value). To understand the Count() function I have explained that with following example: Create Table users ( FirstName varchar(50), City varchar(50) ) Insert into users (FirstName,City) values(null,'Noida') Insert into users (FirstName,City) values('vijend...
When we want to add,delete and delete the coloum in the exiting table then we use Alter Command. Add a Column in a Table Syntex: ALTER TABLE tableName ADD columnname datatype Example: ALTER TABLE Emp ADD City Varchar(500) null Add More than one colum at a time: ALTER TABLE Emp ADD (City Varchar(500) null,Country Varchar(500) null) Delete a colum from the Table Syntex: ALTER TABLE tableNa...
It's fast, easy and free! Submit articles, get your own blog, ask questions & give answers in the forums, and become a better developer, faster.
enter your email address:
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18