August 3, 2012

Make some free phone memory in Android

Generally if you install any application in Android it goes automatically to Phone storage. So if you want to make some more space for phone...

Generally if you install any application in Android it goes automatically to Phone storage.
So if you want to make some more space for phone storage we need to move application to
USB storage.
Use below sequence of actions to accomplish this.

Settings =>Manage Applications =>Application (That you want to move USB storage) =>Move to USB storage.
Now you can check internal phone storage space.

That’s It.
Enjoy Learning.

No new Gmail notification in Android

Recently Gmail notification was stopped working on my android. I figured out how I can restore it back. There are some steps that we need to...

Recently Gmail notification was stopped working on my android.
I figured out how I can restore it back.
There are some steps that we need to follow for the same.

 

Step 1:


Settings =>
Manage Applications => All => Gmail => Clear Cache & Clear data.

 

Step 2:

 

Settings  =>  Accounts & Sync => Auto sync on

 

Step 3:

 

Settings  => Accounts & Sync  => Google  => Sync Gmail on

 

Try above steps hopefully it should work now.

That’s It.
Enjoy Learning.

May 2, 2012

Host ASP.Net 4.0 application on IIS

If you are getting this type of error when you trying to host .Net 4.0 website on IIS it means you have not registered 4.0 framework on IIS....

If you are getting this type of error when you trying to host .Net 4.0
website on IIS it means you have not registered 4.0 framework on IIS.

image

Go to visual studio 2010 command prompt and run this command

aspnet_regiis.exe –i

Now try to run your application hopefully you will not receive same error.

That’s It.
Enjoy Learning.

May 1, 2012

Twitter API resource

You can find all details regarding twitter API from here. https://dev.twitter.com/ How can we integrate our web application with twitter? Yo...

You can find all details regarding twitter API from here.
https://dev.twitter.com/

How can we integrate our web application with twitter?
You can find all resources regarding integration with web
application.

That’s It.
Enjoy Learning.

April 30, 2012

Get Facebook user Emailid in ASP.Net

Using JavaScript SDK we can access user’s emailed in Facebook application. Here is working example for ASP.Net.   <% @ Page Language =...

Using JavaScript SDK we can access user’s emailed in Facebook application.
Here is working example for ASP.Net.
 

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

<!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>
    <style type="text/css">
        #login
        {
            width: 95px;
        }
    </style
>
</
head
>
<
body>
    <button id="login" class="fb-button">
        Login</button>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
    <div id="fb-root">
    </div>
    <script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
    <script type="text/javascript">
        FB.init({
            appId:'APP ID',
            xfbml:true,
            status:true, //check login status
            cookie:true, //enable cookies to allow server to access session,
            xfbml:true, //enable XFBML and social plugins
            oauth: true, //enable OAuth 2.0
            channelUrl: 'http://localhost/channel.htm' //custom channel
        });
        $('#login').bind('click', function () {
            FB.login(function (response) {
                if (response.authResponse) {
                    FB.api('/me', function (response) {
                        $("#txtUser").val(response.id);
                        $("#txtEmail").val(response.email);
                        FB.logout(function (response) {
                        });
                    });
                }
            }, { scope: 'email' });
        });
    </script>
    <form id="form1" runat="server">
    <div>
        <b>User Details</b><br />
        <br />
        <table align="left">
            <tr>
                <td>
                    UserID:
                </td>
                <td>
                    <asp:TextBox ID="txtUser" runat="server" CssClass="input1" Width="100px"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    EmailID:
                </td>
                <td>
                    <asp:TextBox ID="txtEmail" runat="server" CssClass="input1" Width="200px"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    </form
>
</
body
>
</
html
>

That’s It.
Enjoy Learning.

April 29, 2012

Click event of Facebook like button

I have embedded Facebook like button in my web application. Is there any method we can capture event on like button click? Yes we can do it ...

I have embedded Facebook like button in my web application.
Is there any method we can capture event on like button click?
Yes we can do it with Facebook JavaScript SDK.

ASP.Net Code Snippet


 
<script type="text/javascript">
    function(d, s, id)
    {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id))
        {
        return;
        }
        js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
        }
        (document, 'script', 'facebook-jssdk'));
    </script>
    <form id="form2" runat="server">
    <div>
        <div id="fb-root">
        </div>
        <fb:like href="http://shatrughnadiary.blogspot.in" send="false" width="450" show_faces="false">
        </fb:like>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
            FB.init({
                status: true, // check login status               
                cookie: true, // enable cookies to allow the server to access the session
                xfbml: true  // parse XFBML
            });       
        </script>
        <script type="text/javascript">
            FB.Event.subscribe('edge.create', function (response) {
                alert('You liked the URL: ' + response);
            });        
    </script
>

This is working sample.

That’s It.
Enjoy Learning.

April 28, 2012

Allow SQL Server and Windows Authentication mode in SQL Server.

We can change authentication mode in SQL Server using SQL Server node properties window. Just we need to check that radio button in below wi...

We can change authentication mode in SQL Server using SQL Server node properties window.
Just we need to check that radio button in below window.

image

That’s It.
Enjoy Learning.

April 27, 2012

Insert different language character in SQL Server

In SQL Server if I want to store Thanks work in a different language. Is it possible in SQL Server? Yes we can do the same in SQL Server. Fo...

In SQL Server if I want to store Thanks work in a different language. Is it possible in SQL Server?
Yes we can do the same in SQL Server. For this we have to create NVARCHAR column of required
size and in data part we have to prefix data with ‘N’ character.

image

That’s It.
Enjoy Learning.

April 26, 2012

How To Make Default Schema for an user In SQL Server

How can we make default schema for any user on a specific database? So that user will work on that schema only it is more securable than wit...

How can we make default schema for any user on a specific database? So that user will work
on that schema only it is more securable than without schema.
We can assign specific schema to specific user. Let’s see how can we do that?

Go to Database ==> Security ==> Users ==> Double click on user name

We will get one window wherein we need to set all values. Following screen will come
once we will click on user name.

image

Here you can assign default schema name.

That’s It.
Enjoy Learning.

April 25, 2012

How to use Facebook plugin in ASP.Net

We can directly use Facebook plugin inside dot net application. Without much hiccups we can use Facebook plugin with greater efficiency. ...

We can directly use Facebook plugin inside dot net application.
Without much hiccups we can use Facebook plugin with greater
efficiency.

<body onload="InitializeFB();">
<form id="form1" runat
="server">
/* Javascript that will initiate Facebook API */   
<script type="text/javascript" language
="javascript">
function InitializeFB() {
window.fbAsyncInit = function() {
//Replace appId with your own
FB.init({ appId: 'Facebook APP ID', status: true, cookie: true,
xfbml:
true
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
} ());
FB.Event.subscribe('comments.add', function(resp) {
for (var i in resp) {
if (resp.hasOwnProperty(i)) {
console.log(i + "   " + resp[i]);
}
}
});
}
</script
>
<
div id
="data-container">
<div id
="fb-root">
</div
>
<div id
="content">
<div id="container" style
="text-align: center important!">
<div id
="right-sidebar">
<div class="facebook-plugin" style
="background-color: #d4dae8;">
</div
>
<div class="facebook-plugin" style
="background-color: #d4dae8; width:98%;">
<fb:like
>
</fb:like
>

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script
>

<fb:comments href=http://shatrughnadiary.blogspot.in canpost="true" num_posts="5" width
="300px">
</fb:comments
>
</div
>
</div
>
</div
>
</div
>
</div>



That’s It
Enjoy Learning.

April 24, 2012

Enable error message in IIS 7.5 for ASP Application

Recently I was trying to host a classic web application on IIS 7.5. But when I was trying to browse app was generating a predefined message....

Recently I was trying to host a classic web application on IIS 7.5.
But when I was trying to browse app was generating a predefined
message.After small R&D I figure out how to enable error message
for classic application in IIS.  

Step 1:
Just click on web sites we will get below default screen.

image

Step 2:
Now click on ASP we will get below settings screen where we can do all necessary changes.
Just make sure Send Errors To Browser should be True.

image

Now if issues come in application a programmer readable error message will be visible to user.

That’s It.
Enjoy Learning,

Read web.config value in JavaScript

We can directly read value of web.config in javascript. Syntax will be something like as below: var value = '<%=ConfigurationManager....

We can directly read value of web.config in javascript.
Syntax will be something like as below:

var value = '<%=ConfigurationManager.AppSettings["DID"].ToString() %>'

That’s it.
Enjoy Learning.

Facebook Graph API reference

You can find all resources of Facebook graph API on below URL. All resources like how to call API,what we need to pass parameters,what API r...

You can find all resources of Facebook graph API on below URL.
All resources like how to call API,what we need to pass parameters,what
API returns?

https://developers.facebook.com/docs/reference/api/

That’s It.
Enjoy Learning.

PARITION BY on two columns

We can use partition by keyword on two fields in SQL Server. Suppose I want to fetch records  max entry of each user of every day. DECLARE ...

We can use partition by keyword on two fields in SQL Server.
Suppose I want to fetch records  max entry of each user of
every day.

DECLARE @Table TABLE
(
LogID INT
,
UserID INT
,
LogonTime
DATETIME
)

INSERT INTO @Table
SELECT 1,3,'2012-04-20 11:11:20.933' UNION
ALL
SELECT 2,3,'2012-04-20 11:11:16.807' UNION
ALL
SELECT 3,5,'2012-04-20 11:12:16.807' UNION
ALL
SELECT 4,3,'2012-04-23 05:11:57.600' UNION
ALL
SELECT 5,4,'2012-04-23 06:23:57.600' UNION
ALL
SELECT 6,4,'2012-04-23 06:30:50.600' UNION
ALL
SELECT 7,3,'2012-04-23 09:30:12.847' UNION
ALL
SELECT 8,5,
'2012-04-23 10:30:12.847'

SELECT * FROM @Table

;WITH CTE
AS
(
SELECT UserID,LogOnTime,ROW_NUMBER() OVER (PARTITION BY UserID,CAST(LogOnTime AS DATE) ORDER BY LogOnTime DESC) AS RNo FROM @Table
)
SELECT UserID,LogOnTime FROM CTE
WHERE
RNo = 1

That’s It.
Enjoy Learning.

April 23, 2012

Authenticate web service in ASP.Net

Using Soap header we can authenticate web services in .net technology.To demonstrate this i have written a web service for this and consumin...

Using Soap header we can authenticate web services in .net technology.To demonstrate this i have written a web service for this and consuming in client application.

Service:

image

Client Application:

image

That’s it.
Enjoy Learning.

Generate select statement for a table in SQL Server

I have tried to write a script that will generate select script for a table .Sometimes it is very difficult for us to write all columns name...

I have tried to write a script that will generate select script for a table .Sometimes it is very difficult for us to write all columns name in select query.To write all fields is easy task because we can write SELECT *. But suppose i want select 99 columns from 100.

T-SQL:

SET ANSI_NULLS ON
GO
SET
QUOTED_IDENTIFIER
ON
GO

/*
  Objective             :Generate Select script for table
  Version               :Beta Version 1.0
  Developed By          :Shatrughna Kumar 
  Last Modified Date:23rd-Apr-2012
*/

CREATE PROCEDURE [dbo].[spGenenrateSelectScript]
(
       @TABLENAME VARCHAR(200
)
)

AS
BEGIN


      DECLARE @COLUMNLISTS VARCHAR(MAX
)
      DECLARE @SELQUERY VARCHAR(MAX
)
      DECLARE @ISTABLENAME VARCHAR(200
)
     
      SET @ISTABLENAME = REPLACE(@TABLENAME,'dbo.',''
)
     
      SELECT @COLUMNLISTS = 
      STUFF((SELECT ','+COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS 
     
WHERE
      TABLE_NAME = @ISTABLENAME
      FOR XML PATH('')),1,1,'')

      SET @SELQUERY = 'SELECT '+@COLUMNLISTS + ' FROM '+ @TABLENAME

      PRINT @SELQUERY
END


That’s It.
Enjoy Learning.

April 17, 2012

How to use ANY keyword in SQL Server

ANY keyword can be very useful in certain cases. I have tried to create one example here to show you how can we use this in our day to day...

ANY keyword can be very useful in certain cases.
I have tried to create one example here to show you how can we use this
in our day to day queries.


CREATE TABLE PostDetails
(
                ID INT, PostDate DATE,TNP INT
)
;
Go
INSERT INTOPostDetails
 VALUES
  (1, '2012/4/1',5),
  (2, '2012/4/2',10),
  (3, '2012/4/3',15)
GO
SELECT * FROM PostDetails
WHERE '2012/4/2' =ANY(SELECTPostDate FROM PostDetails);


That's It.
Enjoy Learning.

April 13, 2012

DROP Primary Key Constraint

How can we delete primary key from a table? Using DROP CONSTRAINT we can do the same. ALTER TABLE < Table Name > DROP CONSTRAINT ...

How can we delete primary key from a table?
Using DROP CONSTRAINT we can do the same.


ALTER
TABLE <Table Name>

DROP CONSTRAINT <Primary Key Constraint Name>


That's It.
Enjoy Learning.
 

April 11, 2012

Show Google Map In ASP.Net

How to display Google Map in ASP.Net Application? We need to call Google Map and accordingly we can organize it on presentation. < scr...

How to display Google Map in ASP.Net Application?
We need to call Google Map and accordingly we can organize it on presentation.

<script type="text/javascript"src="http://maps.googleapis.com/maps/api/js?sensor=false">
</script
>
<script language="javascript" type
="text/javascript">

        varmap;
        vargeocoder;
        functionInitializeMap() {

            varlatlng = new google.maps.LatLng(0, 0);
            varmyOptions =
        {
            zoom: 8,
            center: latlng,
            mapTypeId:google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true,
            draggable:false,
        };
            map = new google.maps.Map(document.getElementById("map"), myOptions);
        }
function ShowMap() {
            geocoder = new google.maps.Geocoder();
            InitializeMap();

            geocoder.geocode({ 'address': 'New Delhi'}, function(results, status) {
                if(status == google.maps.GeocoderStatus.OK) {
                   map.setCenter(results[0].geometry.location);
                    var marker = newgoogle.maps.Marker({
                        map: map,
                        position:results[0].geometry.location
                    });
                    if (results[0].formatted_address) {
                        region =results[0].formatted_address + '';
                    }
                    var infowindow = newgoogle.maps.InfoWindow({content: 'New Delhi'});
                    infowindow.open(map,marker);
                   

                    google.maps.event.addListener(marker,'click', function(){
                    infowindow.open(map,marker);
                       
                    });

                }
                else{
                    alert("Geocode was not successful for the following reason: " + status);
                }
            });


        }

<body onload="InitializeFB();">

<formid="form1"runat="server">

<div  id="map"style="height: 400px;width: 98%;">
</div>

</body>

That's It.
Enjoy Learning.


 

Convert string to image in C#

We can convert string to image in C#.Here I am trying to convert string “Google Blogger” to image. System.Drawing. Color FontColor = System...

We can convert string to image in C#.Here I am trying to convert
string “Google Blogger” to image.

System.Drawing.
Color FontColor = System.Drawing.Color.Blue;
System.Drawing.
Color BackColor = System.Drawing.Color.White;
string FontName = "Times New Roman";
int FontSize = 12;
int Height = 5;
int Width = 115;
string FileName = Server.MapPath("\\Location\\") + "GenImage.jpeg"
;

Bitmap objBitmap = new
Bitmap(Width, Height);
Graphics objGraphics = Graphics.FromImage(objBitmap);
System.Drawing.
Color objColor;
System.Drawing.
Font objFont = new System.Drawing.Font(FontName, FontSize);
PointF objPoint = new
PointF(1f, 1f);
SolidBrush objBrushForeColor = new
SolidBrush(FontColor);
SolidBrush objBrushBackColor = new
SolidBrush(System.Drawing.Color.FromArgb(226, 221, 228)); objGraphics.FillRectangle(objBrushBackColor, 0, 0, Width, Height);
objGraphics.DrawString(
"Google Blogger", objFont, objBrushForeColor, objPoint);
objBitmap.Save(FileName,
ImageFormat
.Jpeg);

That's It.
Enjoy Learning.