Tuesday, September 18, 2012

google


<!-- Place this tag where you want the +1 button to render -->
<g:plusone annotation="inline"></g:plusone>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

ID

declare @IDs varchar(max)='1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39'

select * from tblGIN

where @IDs is null or ',' + REPLACE(@IDs,' ','') + ','like '%,'+CAST(numGINID as nvarchar(max))+',%'

------------------------------------------------------------------------------------------------

create procedure samplesp

(

@IDs nvarchar(max)

)

as

begin

select * from tblGIN

where @IDs is null or ',' + REPLACE(@IDs,' ','') + ','like '%,'+CAST(numGINID as nvarchar(max))+',%'

end

-----------------------------------------------------------------

----------

 bulk inset into temptable 2ways use in real time



 method 1:

select * into #temp123 from tblGIN

select * from #temp123

drop table #temp123

method: 2

Create table #tempemp(id int,empname varchar(50))

insert into #tempemp

select id,empname from tableEmp

select * from #tempemp

drop table #tempemp

 

SessionTimeIncrease


private void Page_Load(object sender, System.EventArgs e)
{
    Response.AddHeader("Refresh", Convert.ToString((Session.Timeout*60)-10));
}

------------------------------------------------------------------------------
<IFRAME id=Defib src="/Defibrillator.aspx" 
     frameBorder=no width=0 height=0 runat="server"></IFRAME>
-----------------------------------------------------------------------------------------------
http://www.codeproject.com/Articles/10550/The-Defibrillator-Keeping-ASP-NET-Session-Alive-Ad

Email Verifier

http://www.email-unlimited.com/tools/verify-email.aspx


http://www.email-unlimited.com/tools/verify-email.aspx?email=srin@gmail.com






http://www.email-unlimited.com/tools/verify-email.aspx?email=srinivas.gavidi@gmail.com



http://bulkemailverifier.com



http://www.email-unlimited.com/tools/verify-email.aspx?email=srinivas.gavidi@gmail.com

 http://support.google.com/mail/bin/answer.py?answer=6596 gq18si650629bkc.129

Cursor

« SQL SERVER – 2005 – A Simple Way To Defragment All Indexes In A Database That Is Fragmented Above A Declared ThresholdSQLAuthority News – SQL Server 2005 is The Data Platform Leader »
SQL SERVER – Simple Example of Cursor – Sample Cursor Part 2
March 5, 2008 by pinaldave
I have recently received email that I should update SQL SERVER – Simple Example of Cursor with example of AdventureWorks database.

Simple Example of Cursor using AdventureWorks Database is listed here.

USE AdventureWorks
GO
DECLARE @ProductID INT
DECLARE @getProductID CURSOR
SET @getProductID = CURSOR FOR
SELECT ProductID
FROM Production.Product
OPEN @getProductID
FETCH NEXT
FROM @getProductID INTO @ProductID
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @ProductID
FETCH NEXT
FROM @getProductID INTO @ProductID
END
CLOSE @getProductID
DEALLOCATE @getProductID
GO


Reference : Pinal Dave (http://blog.SQLAuthority.com)

Cache

http://blogs.technet.com/b/stefan_gossner/archive/2005/07/11/407522.aspx


<asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled"></asp:TextBox>

You can disable ASP.Net output caching for the entire application by putting it in your web.config file.

<configuration>
    <system.web>
        <caching>
            <outputCache enableOutputCache="false">
            </outputCache>
        </caching>
    </system.web>
</configuration>
But unless you're actually putting anything in the cache in the first place, you don't have anything to worry about.

-------------------------------------------------
Declarative Approach:

<%@ OutputCache Duration="60" Location="Server" VaryByParam="None" %>

Programmatic Approach:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Server);

What I found is that when using CTRL-F5 the declarative approach always returned the cached version but the programmatic approach returned a new version from the server. Not what I was looking for as I needed to control the amount of time but without affecting any other caching features.

Finally someone in the ASP.NET caching newsgroup was able to point me to the solution for this. There is an extra property that needs to be set to ensure that the cache gets persisted through CTRL-F5.

Here is now the complete code:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetValidUntilExpires(true);

-------------------------------------------------------------------


up vote
1
down vote
accepted
you cannot clear browser cache.the only idea is declare a session variable in c# code in page load and set its value is 1 at the very first time

if (!IsPostBack)
            {
Session["refresh"]="1"
}
you will need to set session variable in image upload button event Session["refresh"]="1" then create a refresh button .in the button event do the following thats all.after completeing your upload,click on the refresh button.then it work as ctrl+f5 button.if you not set the session value 0 in refresh button event the last event is again takesplace.if you enter a value in database,the same task takesplace if you not set session variable 0.

   if(Session["refresh"].ToString()=="1")
   {
      Response.Write("<script type='text/javascript'>locaton.reload()</script>");
      Session["refresh"]="0";
    }
-----------------------------------------------------------
<asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Disabled"></asp:TextBox>
---------------------------------------------------------------------------------

WPF

<Window x:Class="WpfApplication4.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Button Name="btn1" Background="Pink"
        BorderBrush="Black" BorderThickness="1"
        Click="OnClick1" ClickMode="Hover">
  ClickMe1
</Button>

<Button Name="btn2" Background="LightBlue"
        BorderBrush="Black" BorderThickness="1"
        Click="OnClick2" ClickMode="Press">
  ClickMe2
</Button>

<Button Name="btn3"
        Click="OnClick3" ClickMode="Release">
  Reset
</Button>
    </Grid>
</Window>
--------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication4
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

            void OnClick1(object sender, RoutedEventArgs e)
        {
            btn1.Background = Brushes.LightBlue;
        }

        void OnClick2(object sender, RoutedEventArgs e)
        {
            btn2.Background = Brushes.Pink;
        }

        void OnClick3(object sender, RoutedEventArgs e)
        {
            btn1.Background = Brushes.Pink;
            btn2.Background = Brushes.LightBlue;
        }

    }
}

WCF


introduction
What is WCF?

WCF is a service Oriented programming in .net framework 3.0 which provide unique platform for all type of Communications in .net for distributed Applications.

It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF.

Basic Bare Bones of WCF

1>Endpoints (ABC terms).

>Address

>Binding

>Contract

All the WCF communications are take place through end point. End point consists of three components.(i.e ABC)

Address:

   Basically URL, specifies where this WCF service is hosted .Client will use this url to connect to the service.

         e.g http://localhost:8071/MyService/Calculator.svc.

Binding:
   Binding will describes how client will communicate with service. There are different protocols available for the WCF to communicate to the Client. You can mention the protocol type based on your requirements.

In My service I used Basic Http Service protocol for communication.i.e wsHttpBinding

Contract:
   Collection of operation that specifies what the endpoint will communicate with outside world. Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client. Each operation is a simple exchange pattern such as one-way, duplex and request/reply.

In My Service Contract is” Service1 “.

Exchange pattern is” request/reply”;

2> Service Contract: Service contracts describe the operation that service can provide

3>Operation Contract: Attribute Which is used to define the Method as part of Service.


Demo of the Calculator Example.
Step By Step Procedure

1>    Creating WCF Service

2>    Consuming WCF Service in Web Application using VS 2008.

3>    Creating WCF Client.

Creating WCF Service.
Steps:

1>    Open  VS 2008 > Projects > Select C#  >  WCF  > WCF Service Library.

2>    Type name of  the service file as u need. In this ex.MyWCFSolution. then click OK.

3>    New Window will open with one Class.cs and Interface .cs File which can be seen in Solution Explore.

4>    Add the Namespace System.ServiceModel and  also add  Reference in Solution Explore.

5>    Type the Code in Interface file and class file as shown below.

Code in Interface(EX: IService1.cs)

[ServiceContract]
    public interface IService1
    {
        [OperationContract]
       int add(int a,int b);

        [OperationContract]
       int Sub(int a, int b);

        [OperationContract]
        int Mul(int a, int b);

        [OperationContract]
        int Div(int a, int b);

        // TODO: Add your service operations here
    }



Code in Class file(EX: Service1.cs)

public class Service1 : IService1
    {
     
        int IService1.add(int a, int b)
        {
            return (a + b);
        }

        int IService1.Sub(int a, int b)
        {
            if (a >= b)
            {
                return (a - b);
            }
            else
            {
                return (b - a);
            }
        }
     
     
        public int Mul(int a, int b)
        {
            return (a * b);
        }

        public int Div(int a, int b)
        {
            if(a>=b)
                try { return (a / b); }
                catch
                { return 0; }
            else
                return (b / a);
        }
    }

Consuming WCF Service in Web Application.

Steps:

1>Create web Application as shown in attachment please download the File.



2> After Creating Desing of the Calculator web application the add reference System.ServiceModel namespace into web application in Solution Explore.

3>Add the WCF Service in visual studio by right click on Reference and select Add service Reference

4>Give the Service hosted Address and click on Go button and select the service which u created I mean in Ex service1.

5>Give the namespace: Name as Myservice and  the click OK .

1>    Creating WCF Client.

In Order to call the Methods (services from WCFService) we need to Create the porxy WCF Client.

Once service is consumed in Application, WCF Client is Created, So Using the name of the Client Name we can call the methods in out applications

EX. In  Our WCF Service we have 4 methods (add, sub, mul, div).

2>      TO get the WCF client name Double click on Service i.e Myservice and take the copy of the Client name.

The fwindow will open in that u take the copy.

3>    Paste the Client Name in Default.cs File get the following code then create the instance of the client as show in below code. Using this porxy client u can call the services of the WCF service as shown in below code.

4>    On paste u get MY.Myservice.Service1Client

5>  Code to be Right in Default.cs in web application(EX:Calculator)

namespace Calculator
{
    public partial class _Default : System.Web.UI.Page
    {
     
        Calculator.Myservice.Service1Client Client = new Calculator.Myservice.Service1Client();
//Creating proxy client instance “Client”
        int a, b;
        protected void Page_Load(object sender, EventArgs e)
        {
         
            Response.Write("MY Calculator");

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);

            int Addition = Client.add(10,20);
            txtResult.Text = Addition.ToString();
        }

        protected void btnsub_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Sub(10, 20);
            txtResult.Text = Addition.ToString();

        }

        protected void btnmul_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
            int Addition = Client.Mul(10, 20);
            txtResult.Text = Addition.ToString();
        }

        protected void btndiv_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Div(10, 20);
            txtResult.Text = Addition.ToString();

        }
    }
}

Testing the application and using WCF services.

1>  Run the WCF service First.(Ex:MyWCFsolution)

2>  Run the wev Application(EX: Calculator)(download the attachements)



Conclusion
Hope this article makes Sense of  basic Idea about WCF. Thank you.

What is WCF?


introduction
What is WCF?

WCF is a service Oriented programming in .net framework 3.0 which provide unique platform for all type of Communications in .net for distributed Applications.

It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF.

Basic Bare Bones of WCF

1>Endpoints (ABC terms).

>Address

>Binding

>Contract

All the WCF communications are take place through end point. End point consists of three components.(i.e ABC)

Address:

   Basically URL, specifies where this WCF service is hosted .Client will use this url to connect to the service.

         e.g http://localhost:8071/MyService/Calculator.svc.

Binding:
   Binding will describes how client will communicate with service. There are different protocols available for the WCF to communicate to the Client. You can mention the protocol type based on your requirements.

In My service I used Basic Http Service protocol for communication.i.e wsHttpBinding

Contract:
   Collection of operation that specifies what the endpoint will communicate with outside world. Usually name of the Interface will be mentioned in the Contract, so the client application will be aware of the operations which are exposed to the client. Each operation is a simple exchange pattern such as one-way, duplex and request/reply.

In My Service Contract is” Service1 “.

Exchange pattern is” request/reply”;

2> Service Contract: Service contracts describe the operation that service can provide

3>Operation Contract: Attribute Which is used to define the Method as part of Service.


Demo of the Calculator Example.
Step By Step Procedure

1>    Creating WCF Service

2>    Consuming WCF Service in Web Application using VS 2008.

3>    Creating WCF Client.

Creating WCF Service.
Steps:

1>    Open  VS 2008 > Projects > Select C#  >  WCF  > WCF Service Library.

2>    Type name of  the service file as u need. In this ex.MyWCFSolution. then click OK.

3>    New Window will open with one Class.cs and Interface .cs File which can be seen in Solution Explore.

4>    Add the Namespace System.ServiceModel and  also add  Reference in Solution Explore.

5>    Type the Code in Interface file and class file as shown below.

Code in Interface(EX: IService1.cs)

[ServiceContract]
    public interface IService1
    {
        [OperationContract]
       int add(int a,int b);

        [OperationContract]
       int Sub(int a, int b);

        [OperationContract]
        int Mul(int a, int b);

        [OperationContract]
        int Div(int a, int b);

        // TODO: Add your service operations here
    }



Code in Class file(EX: Service1.cs)

public class Service1 : IService1
    {
     
        int IService1.add(int a, int b)
        {
            return (a + b);
        }

        int IService1.Sub(int a, int b)
        {
            if (a >= b)
            {
                return (a - b);
            }
            else
            {
                return (b - a);
            }
        }
     
     
        public int Mul(int a, int b)
        {
            return (a * b);
        }

        public int Div(int a, int b)
        {
            if(a>=b)
                try { return (a / b); }
                catch
                { return 0; }
            else
                return (b / a);
        }
    }

Consuming WCF Service in Web Application.

Steps:

1>Create web Application as shown in attachment please download the File.



2> After Creating Desing of the Calculator web application the add reference System.ServiceModel namespace into web application in Solution Explore.

3>Add the WCF Service in visual studio by right click on Reference and select Add service Reference

4>Give the Service hosted Address and click on Go button and select the service which u created I mean in Ex service1.

5>Give the namespace: Name as Myservice and  the click OK .

1>    Creating WCF Client.

In Order to call the Methods (services from WCFService) we need to Create the porxy WCF Client.

Once service is consumed in Application, WCF Client is Created, So Using the name of the Client Name we can call the methods in out applications

EX. In  Our WCF Service we have 4 methods (add, sub, mul, div).

2>      TO get the WCF client name Double click on Service i.e Myservice and take the copy of the Client name.

The fwindow will open in that u take the copy.

3>    Paste the Client Name in Default.cs File get the following code then create the instance of the client as show in below code. Using this porxy client u can call the services of the WCF service as shown in below code.

4>    On paste u get MY.Myservice.Service1Client

5>  Code to be Right in Default.cs in web application(EX:Calculator)

namespace Calculator
{
    public partial class _Default : System.Web.UI.Page
    {
     
        Calculator.Myservice.Service1Client Client = new Calculator.Myservice.Service1Client();
//Creating proxy client instance “Client”
        int a, b;
        protected void Page_Load(object sender, EventArgs e)
        {
         
            Response.Write("MY Calculator");

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);

            int Addition = Client.add(10,20);
            txtResult.Text = Addition.ToString();
        }

        protected void btnsub_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Sub(10, 20);
            txtResult.Text = Addition.ToString();

        }

        protected void btnmul_Click(object sender, EventArgs e)
        {
a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
            int Addition = Client.Mul(10, 20);
            txtResult.Text = Addition.ToString();
        }

        protected void btndiv_Click(object sender, EventArgs e)
        {
            a = Convert.ToInt32(txt1st.Text);
            b = Convert.ToInt32(txt2nd.Text);
int Addition = Client.Div(10, 20);
            txtResult.Text = Addition.ToString();

        }
    }
}

Testing the application and using WCF services.

1>  Run the WCF service First.(Ex:MyWCFsolution)

2>  Run the wev Application(EX: Calculator)(download the attachements)



Conclusion
Hope this article makes Sense of  basic Idea about WCF. Thank you.