GoMo: An Initiative From Google

Mobile phones are increasingly being used for browsing the Internet. Though the number of people using mobile devices to browse the Internet is still comparatively limited, the fact remains that this number is increasing rapidly

Google says ” Just because you can see your desktop site on a mobile phone doesn’t mean it’s mobile-friendly. Mobile sites are designed for the small screen, with the needs of mobile users in mind. A mobile-friendly site can help your business connect with customers and drive conversions

Therefore, it is recommended to test your website to find out how it looks like on a mobile/smart phone.

Visit the Google’s free GoMoMeter website to test your website for a mobile device.

Enter you website’s URL,select your business category and answer 5 simple question asked and wait for the results, you should be getting an output as the one below in a few seconds.

Embarrassing isn’t it ? ;) Will be using WPtouch plugin soon, will keep you’all informed.

Pendrive showing all folders as shortcuts

Hello, have you ever come across this kind of wierd situation?

When you connect your pen drive to your computer, you find that all your files and folders have now become shortcuts ? No matter which desktop or laptop you try putting your pen drive into, your data just wont show up!

If your answer to the above question is a YES! then I have a solution for you. Follow the steps given below and you should be able to get back all your data in the next 2 minutes.

Why did this happened ?

Your pen drive or memory card may have been infected with a  virus or some Trojans (like BUOUFO, QWERT etc) or autorun.inf worm.

How to Fix this  problem?

Open your command prompt, {How to open a command prompt in Windows 7 or XP}

Here lets assume your removable drive to be E:, and enter this command:

attrib -h -r -s /s /d e:\*.*

(replace the letter e with your  “removable drive” letter showed under “My Computer”).

and tada !!! In most cases this is all you will need to do, but if still your file doesn’t show up then read on :( …

You will have to use some strong anti-virus or anti-malware programs to eliminate these virus and trojans. Below are links to some trusted and recommended Antivirus and anti-malware program that you can use.

http://download.cnet.com/Malwarebytes-Anti-Malware/3000-8022_4-10804572.html

http://free.avg.com

 

Read connectionString from web.config

It is a good practice to store the connection string for your application in a config file rather than as a hard coded string in your code. It becomes much easier for you later on when you may want to change the connectionString.

How to add a connectionString to a Web.config file ?

Under the connectionString node, add a  name and a connectionString. Here name represent your connection string, source will be your computer name, Initial catalog will be your database name, and finally id and pasword will be your database server name and password.

WEB.CONFIG

{code type=html}

<connectionStrings>

<add
name=”localConn”
connectionString=”Data Source=YASSER-VAIO;Initial Catalog=ssc;
Persist Security Info=True;
User ID=sa;
Password=shaikh”
providerName=”System.Data.SqlClient”/>

</connectionStrings>

{/code}

SOMEPAGE.ASPX.CS

We can use the ConfigurationManager class present in System.Configuration namespace to get a specific connectionStrings from the web.config file. You will simply need to provide the name of the connectionString(‘localConn‘) as shown in the example below.

{code type=javascript}

private string GetConnectionString()
{

var conString = ConfigurationManager.ConnectionStrings[“localConn”];

if(conString == null)
{
throw new Exception(“Connection String is not defined! Please check your Web.config”);
}

return conString.ConnectionString;

}

{/code}

Happy Coding !! :)

Display result of a stored procedure in a GridView

This tutorial will tell you how to display data into a Grid View using a stored procedure.

Before using the code below you need to have the following:

1. SQL stored procedure (in the below example I have created a stored procedure named “myStoredProcedure“)

2. Add a gridView control to the page.

The code below is pretty much simple and self-explanatory, please feel free to writeIn if you have any doubts.

{code type=javascript}

const string storedProcedureName = “myStoredProcedure”;

string connectionString = “Data Source=YASSER;Initial Catalog=YS;Persist Security Info=True;User ID=sa;Password=shaikh”;

var connection = new SqlConnection(connectionString);
var command = new SqlCommand(storedProcedureName, connection);

command .CommandType = CommandType.StoredProcedure;
command .Parameters.Add(“myID”, “someValueToBePassed”);

try
{
connection.Open();

gridView.DataSource = command.ExecuteReader();
gridView.DataBind();  }
catch (Exception)
{
throw;  }
finally
{
connection.Close();
command.Dispose();  }

{/code}

How to include a CSS in an HTML file

Below is my sample stylesheet created, with a name say style.css

File style.css

{code type=css}
body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:”Times New Roman”;
font-size:20px;
}

{/code}

To include the above css file in an HTML file, you need to use the link tag. In the link tag using the href attribute you can specify the path and the name of the stylesheet which you want to inlcude, and the type attribute here has a value of “text/css” .

{code type=html}

<html>
<head>
<link href=”style.css” rel=”stylesheet” type=”text/css”>
</head>

<body>

<h1>This is an HTML File</h1>
<p>Check the above link statement present in the head tag .</p>

</body>
</html>

{/code}

Check if Trigger exists in SQL

SELECT * FROM sys.triggers, will return a table that contains a row for each object that is a trigger, with a type of TR or TA.

SELECT count(*) FROM sys.triggers where name = ‘MyTrigger’, can be used if one need to look if a particular trigger exists or not. The above line of code will return a 0 if the specified trigger is not present, otherwise 1 will be returned.

One can also use

IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N’[dbo].[trgrName]‘))

All of the above method are valid for all versions of SQL Server.