This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Me And My Respected Teacher Mr Kamal Sheel Mishra

Mr. K.S. Mishra is HOD of Computer Science from SMS Varanasi where I have completed my MCA

Me And My Respected Teacher Mr Udayan Maiti

Mr. Udayan Maiti is a senior .Net Expert and has guided many professionals of multi national Companies(MNC)

Me And My Best Friend Mr Ravinder Goel

Mr. Ravinder Goel is a senior Software Engineer and now he is working Wipro Technology

Friday 30 August 2013

How to Implementing Polymorphism is C#.Net

What is Polymorphism?


Polymorphism means one name, many forms .In other words polymorphism can be explained as one entity having multiple forms. Polymorphism is important feature of OOPS.By using this feature of polymorphism, you can create multiple methods having same name. For Example, suppose you have to write program that calculates the area of triangle, circle, rectangle, square .With the Polymorphism feature, you can create four different methods with same name Area for each. The number and types of parameters and return types of methods may be different. It provides various advantages which are follows:


  1. Help classes to provide different implementations for method that are called using same name
  2. Help you to call a method of a class regardless of the specific implementations of the method
  3. Allow you to invoke method of a derived class through  base class reference at run time in C#, polymorphism is following two types:


1.    Compile –Time Polymorphism
2.    Run-Time Polymorphism

Compile -Time Polymorphism:

When a compiler compiles a program, the compiler has information about the method arguments; accordingly, the compiler binds the appropriate method to the respective object at the compile time itself. This process is called compile-time polymorphism or early binding. You can implement its through overloaded methods and operators. The arguments passed to methods are matched in terms of number, type and order; and the overloaded methods are invoked.

Compile-Time Polymorphism can be implemented by using two methods:


  1.  Method Overloading
  2. 2 Operator Overloading

Method Overloading: When the methods defined in a class behave according to number and types of parameters passed to them they are called overloaded methods and this behavior of the methods is called method overloading .when you overload a method, then the overloaded version of the method that is called by a method call at run time is determined by the signature with which the method is called. A method signature comprises the following attributes:


  1.    The name of the method is same
  2.     The number of the parameters passed to the method
  3.     The data type of the parameters
  4.      The order in which the parameters are passed


Implementing Method Overloading with Example:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Polymorphism
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public class Shape
{
// create method Area with one Parameter for Calculate Area of Square
public void Area(double side)
{
MessageBox.Show("Area of Square is=" + (side * side));
}
// create method Area with two Parameters for Calculate Area of Rectangle
public void Area(double length,double width)
{
MessageBox.Show("Area of Rectangle is=" + (length * width));
}
}

private void button1_Click(object sender, EventArgs e)
{
Shape sp = new Shape();
//concept of Method Overloading
sp.Area(Convert.ToDouble(txtside.Text));
sp.Area(Convert.ToDouble(txtlength.Text), Convert.ToDouble(txtwidth.Text));

}
}
}





                                                                                                               Operator Overloading

Thursday 29 August 2013

How Rename any table Drop any column in Sql Server 2008

How  rename any table ,Drop any colum in Sql Server 2008

create database test
use  test
--To create  table, use the following syntax

create table Sqlpractice(Id int identity(100,5) primary key,Name varchar(50),Dob date not null default getdate(),age int not null default 0)

--To rename  table, use the following syntax

sp_rename 'Sqlpractice','testsql'

--To insert into  table, use the following syntax and after insert how to select data
insert into testsql values('Dinesh Ramdeen','','')
insert into testsql values ('Rohit Singh','07/23/1987',24)
Select * from testsql


 --To rename a column in a table, use the following syntax

sp_rename 'testsql.Dob','DateOfBirth','column'

--To add a column in a table, use the following syntax

alter table testSql add  Address varchar(50)

--To change datatype with column in a table, use the following syntax

alter table testsql alter column  Address nvarchar(50)

--To delete a column in a table, use the following syntax

alter table testsql drop column Address

--How to create another table Student  which has the same structure and same data like testSql table

select *  into Student from testSql

--How to create another table Emp  which has the same structure  like testSql table

select *  into Emp from testSql where 0=1




Monday 26 August 2013

What is Request and Response objects in Asp.Net


What is Request and Response objects in Asp.Net

Request  and Response are the properties of the Page class. The Request property allows you to access the HTTPRequest object, which contains information,such as path of the request, about the HTTP request for the page .It is a input stream of client. The Response property allows you to access the HTTPResponse object, which in turn allows you to send data to the browser as the result of the request.It is an output stream of Client 

                     In fact, Request and Response properties map directly to HttpRequest and HttpResponse objects respectively. Therefore,  you can directly access these objects in ASP.NET pages by using the Request and Response properties.

Request =>Read   Response=>Write


Example with Request and Response 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class RequestResponse : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{



}
protected void btnResponse_Click(object sender, EventArgs e)
{

Response.Write("<b><i>Request Type=</i></b>" + Request.RequestType + "</br></br>");

Response.Write("<b><i>BrowserName=</b></i>" + Request.Browser.Type + "</br></br>");

Response.Write("<b><i>IsJavaScript Support=</i></b>" + Request.Browser.JavaScript + "</br></br>");

Response.Write("<b><i>IsCookies Support=</i></b>" + Request.Browser.Cookies + "</br></br>");

Response.Write("<b><i>Request Type=</i></b>" + Request.RequestType + "</br></br>");

Response.Write("<b><i>Language=</i></b>" + Request.UserLanguages[0] + "</br></br>");

Response.Write("<b><i>Ip Address=</i></b>" + Request.UserHostName + "</br></br>");

Response.Write("<b><i>Url=</i></b>" + Request.Url + "</br/></br>");

Response.Write("<b><i>User Agent=</i></b>" + Request.UserAgent + "</br/></br>");

Response.Write("<b><i>User Host Name=</i></b>" + Request.UserHostName + "</br></br>");

Response.Write("<b><i>Physical Path=</i></b>" + Request.PhysicalPath + "</br></br>");

Response.Write("<b><i>Physical Application Path=</i></b>" + Request.PhysicalApplicationPath + "</br></br>");

Response.Write("<b><i>Path=</i></b>" + Request.Path + "</br></br>");

Response.Write("<b><i>Application Path=</i></b>" + Request.ApplicationPath + "</br></br>");

}
}


Friday 23 August 2013

How to refresh Images which are present in database with Web Services in Asp.Net

How to refresh images which are present in database with Web Services in Asp.Net


Note: My concept in this code is we create a web services and with the help of this web services  we  want to show all data (images,links,name) one by one in another  website

We take  a web service in  our Website and create a web Method………………………………………

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

public WebService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

                          
[WebMethod]
public void RefreshImage(ref int a, ref string b, ref string c, ref string d)
{
SqlConnection con = new SqlConnection(@"Data Source=KUSH-PC\KUSH;Initial Catalog=test;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select top 1 * from SiteImage order by NEWID()", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
a =(Int32) dr[0];
b = dr[1].ToString();
c = dr.GetString(2);
d= dr[3].ToString();

}
con.Close();

}

}

We take  another web Site and call above Web Services ………………………….
// code for Default.aspx.…………………………………..

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblimageid" runat="server" Text="Label"></asp:Label>
<asp:ImageButton ID="ImageButton1" runat="server" Height="69px" Width="64px" />
<br />
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
<asp:Timer ID="Timer1" runat="server" Interval="1000" Enabled="true">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>

// code for Default.aspx.cs…………………………………..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int a = 0;
string b = ""; string c = ""; string d = "";
localhost.WebService ww = new localhost.WebService();
ww.RefreshImage(ref a,ref b, ref c, ref d);
lblimageid.Text = a.ToString();
HyperLink1.Text = b;
HyperLink1.NavigateUrl = c;
HyperLink1.Target = "_blank";
ImageButton1.ImageUrl = "~/SiteImage/" + d;
ImageButton1.PostBackUrl = b;
ImageButton1.ToolTip = c;
}
}



Output: Images which are saving in our database are show in our output one by one within a difference of one second

select top 1 * from SiteImage order by NEWID()