Loading ...

Who is online?  0 guests and 0 members
home  »  blogs  »  Vijendra Shakya

Communifire Blogs

Vijendra Shakya : Most Recent postings

Vijendra Shakya

C#: Find all "DayOfWeek" in a year

9/19/2010 by Vijendra Shakya · 0 · 2712

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...

Vijendra Shakya

C#: Find Fibonacci Series

9/5/2010 by Vijendra Shakya · 1 · 6023

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...

Vijendra Shakya

Difference between Literal and Label in ASP.NET

7/13/2010 by Vijendra Shakya · 1 · 13368

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 ...

Vijendra Shakya

Calculate Business days in ASP.NET C#

6/18/2010 by Vijendra Shakya · 0 · 12367

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...

Vijendra Shakya

Find Leap year in ASP.NET(C#)

6/17/2010 by Vijendra Shakya · 4 · 5989

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...

Vijendra Shakya

Delete,Truncate All Table's data from Database in SQL Server

6/17/2010 by Vijendra Shakya · 0 · 3460

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:...

Vijendra Shakya

Generate BarCode in ASP.NET

5/4/2010 by Vijendra Shakya · 4 · 14953

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....

Vijendra Shakya

Find Maximum value from an Enum

11/29/2009 by Vijendra Shakya · 2 · 3431

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...

Vijendra Shakya

What is Paged DataSource?

11/12/2009 by Vijendra Shakya · 0 · 3261

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...

Vijendra Shakya

Find Date after a given week(s) or month(s)

11/4/2009 by Vijendra Shakya · 1 · 2352

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...

Vijendra Shakya

Find Enum Name from Value

10/30/2009 by Vijendra Shakya · 0 · 3080

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...

Vijendra Shakya

Auto refresh page

10/6/2009 by Vijendra Shakya · 10 · 6261

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 ...

Vijendra Shakya

Bind Repeater With ArrayList

9/29/2009 by Vijendra Shakya · 0 · 5440

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...

Vijendra Shakya

Difference Between COALESCE() AND ISNULL()

7/19/2009 by Vijendra Shakya · 0 · 3973

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...

Vijendra Shakya

What is SQLCommand Objects in ADO.NET

7/12/2009 by Vijendra Shakya · 2 · 4704

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...

Vijendra Shakya

How To Rename ColumnName in SQL

7/2/2009 by Vijendra Shakya · 0 · 2823

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…

Vijendra Shakya

Find Nth highest salary in SQL

6/27/2009 by Vijendra Shakya · 4 · 22829

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...

Vijendra Shakya

Count Number of Tables/Columns in Database

6/27/2009 by Vijendra Shakya · 0 · 6319

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...

Vijendra Shakya

How do we create,Read,Delete Cookies in Asp.net

6/24/2009 by Vijendra Shakya · 1 · 4526

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...

Vijendra Shakya

Store and Retrieve values from Session

6/23/2009 by Vijendra Shakya · 0 · 2492

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...

Vijendra Shakya

Difference between Delete and Truncate in SQL

6/21/2009 by Vijendra Shakya · 0 · 2260

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...

Vijendra Shakya

AND & OR Operator in SQL

6/16/2009 by Vijendra Shakya · 0 · 1397

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...

Vijendra Shakya

DISTINCT In SQL

6/16/2009 by Vijendra Shakya · 0 · 1508

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')...

Vijendra Shakya

Use of Count Function in SQL

6/16/2009 by Vijendra Shakya · 0 · 4550

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...

Vijendra Shakya

Alter table command In MSSQL

4/17/2009 by Vijendra Shakya · 0 · 3738

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...

  • Page 1 of 2 (46 items)
  • « Previous 
  • 1
  • 2
  • Next »
  •   Go to page:  [Go]

Product Spotlight

ASP.NET Hosting Spotlight

Join CodeAsp.Net for FREE Today!

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:

 

Quick Vote

What kind of email newsletter would you prefer to receive from CodeAsp.Net?