Thursday, October 23, 2014

Execute code online

Online compiler and debugging tool which allows you to compile source code and execute it online in more than 60 programming languages.

http://ideone.com/

Monday, October 28, 2013

HTTP Error 503. The service is unavailable.

I started receiving "HTTP Error 503. The service is unavailable" error for localhost after re configuring the default website on local machine.

After some investigation I noticed the Application pool had stopped.

I restarted the Application pool

  • Open the Internet Information Services (IIS 7) Manager
  • Select the Application Pools node under the root node in the left hand side frame.
  • Right Click on the application pool website uses.  If the service is stopped, start it.  If the service is running, restart it.


Ran the website and it gave the "HTTP Error 503. The service is unavailable" error again. Checked the application pool to notice it had stopped automatically.

This turned out to be a custom account issue.
The password for user that application pool was running under was changed some time ago but it kept running until changes were made to the website settings in IIS7.

Reset the identity for the pool and started the application pool.

  • In application pool -> Advanced Settings->Click on Identity->enter username and password when prompted 
  • Restart the Application pool
  • Run the website

That did the trick! Issue resolved!

Thursday, March 14, 2013

Increase Database Mail Size Limit

sp_send_dbmail allows you to send emails with attachments. However by  default, Database Mail limits file attachments to 1 MB per file.

You can configure database mail to allow larger sizes.
Expand the Management tab, right-click on Database Mail,
Click on Configure Database Mail.
Select "View or change system parameters"
"Maximum File Size (Bytes)"  is the option you can change to configure the attachment size.

Friday, March 2, 2012

Websites that can help your business to reach out to local customers

Angies list - Subscription based for consumers, Free for businesses
CitySearch - Free to join, paid upgraded available
Google Places - Free
Yahoo!Local - Free to join , upgrades available.
Yelp - Free to join, upgrades available

Sunday, February 5, 2012

Reference not copied to bin folder when complied in Visual Studio

A reference to third party dll  is not copied to bin folder even when "Copy Local" is set to True.

Make sure project file has following tag in it

<Private>True</Private>

If this does not help try adding a "using" or "import" in your code as dynamically loaded reference could cause this issue.
It seems if you are not using the library directly in the code Visual Studio detects that its not used and does not include in the output.

Sunday, May 15, 2011

Print Excel Worksheet With Comments

Print comments

If your worksheet contains comments, you can print them as they appear on the sheet or at the end of the sheet.
  1. Click the worksheet that contains the comments that you want to print.
  2. To print the comments in place on the worksheet, display them by doing one of the following:
  • To display an individual comment, click the cell that contains the comment, and then on the Review tab, in the Comments group, click Show/Hide Comment.
 Tip   You can also right-click the cell and then click Show/Hide Comments on the shortcut menu.
  • To display all comments, on the Review tab, in the Comments group, click Show All Comments.
Excel Ribbon Image
 Tip   You can move and resize any overlapping comments.

  1. On the Page Layout tab, in the Page Setup group, click the dialog box launcher Button image next to Page Setup.
Excel Ribbon Image
  1. On the Sheet tab, in the Comments box, click As displayed on sheet or At end of sheet.
  2. Click Print.
 Tip   To see how comments are printed, you can click Print Preview before you click Print.

This article is copied from http://office.microsoft.com/en-us/excel-help/print-comments-HP001216408.aspx 

Wednesday, April 20, 2011

Referencing Custom Master Page Properties From Content Pages

To reference master page properties from content pages
  • Create a public property in the master page code-behind file
  • Add the @ MasterType declaration to the ASPX content page
    <%@ MasterType VirtualPath="~/Site.master" %>
  • Reference the master page property from content page as
    Master.[property_name]



Friday, March 18, 2011

Connecting to FTP server via IE7 or up

When you try to connect to ftp server via IE 7 or up you may get "Internet Explorer cannot display the webpage" error.

Try steps below to be able to connect FTP via IE.

1.            Start Internet Explorer.
2.            On the Tools menu, click Internet Options.
3.            Click the Advanced tab.
4.            Under Browsing, click the Enable folder view for FTP sites check box.
5.            Click OK.
6.            Close IE
7.            Restart and Test

If above is selected and you get the  page that give “Internet Explorer cannot display the webpage” message,

Click “View”  from top menu of IE. ( If View is not visible click Alt key to make it appear under address bar) 
Click  “Open FTP site in Windows Explorer” menu option,  to open up your ftp folder in windows explorer.

Friday, February 18, 2011

Validator Controld in ASP.NET

ASP.NET provides an easy to use  set of validation controls to check for errors in user input and display messages to the user.

RequiredFieldValidator - Checks validated control contains value.

CompareValidator - Checks user input against constant value, value of another control or for a specified data type.

RangeValidator - Checks if user input is between specified lower and upper boundaries.

RegularExpressionValidator - Checks if user input matches a patter defined by a regular expression.

CustomValidator - Checks user input against validation logic that developer writes.


Saturday, January 15, 2011

What is the difference between Bind and Eval in ASP.NET?


Eval is one way (read only) databinding

Bind allows two way (read/write) databinding.

Monday, December 20, 2010

Formatting float to varchar in non scientific notation

When trying to convert a float value to varchar "Convert" returns string that represents the float value in sceientific notation.

e.g.

DECLARE @Float as float =1900000.0

SELECT CONVERT (varchar(50),@Float)

Results
---------
1.9e+006

However if you would like a string "1900000.0" you can use one of the methods below

DECLARE @Float as float =1900000.0

SELECT CONVERT(varchar(100), CAST(@Float AS decimal(38,1)))
SELECT ltrim(STR(@Float, 50, 1))

Both of them return a string
--------------------------
1900000.0

Wednesday, November 24, 2010

Find dependencies on a table(MS SQL)

The following script lists all the procedures that reference a given table name, along with referenced columns. (Does not work on dynamic queries)

DECLARE @TableName varchar(100)
SET @TableName = 'MyTable'

SELECT
SourceSchema = OBJECT_SCHEMA_NAME(sed.referencing_id)
,SourceObject = OBJECT_NAME(sed.referencing_id)
,ReferencedDB = ISNULL(sre.referenced_database_name, DB_NAME())
,ReferencedSchema = ISNULL(sre.referenced_schema_name,
OBJECT_SCHEMA_NAME(sed.referencing_id))
,ReferencedObject = sre.referenced_entity_name
,ReferencedColumnID = sre.referenced_minor_id
,ReferencedColumn = sre.referenced_minor_name
FROM sys.sql_expression_dependencies sed
CROSS APPLY sys.dm_sql_referenced_entities(OBJECT_SCHEMA_NAME(sed.referencing_id)
+ '.' + OBJECT_NAME(sed.referencing_id), 'OBJECT') sre
WHERE sed.referenced_entity_name = @TableName
AND sre.referenced_entity_name = @TableName

Sunday, October 10, 2010

Google Apps Standard Edition

Link to set up domain for Google Apps Standard Edition is as below http://www.google.com/a/cpanel/domain/new

Friday, September 24, 2010

MyMobiler-nice tool to remote control a mobile device

Nice tool to have when developing mobile applications. It works as remote desktop for your mobile device making testing on actual device easier.


MyMobiler v1.25 (02/07/2008) - FREEWARE

* View your mobile screen on your desktop.
* Control your mobile by using desktop keyboard and mouse.
* Copy/Cut/Paste text between mobile and desktop.
* Capture mobile screen.
* Drag and drop files to your mobile.
* Support ActiveSync / IP Connection
* Support Mobile Explorer (File Browse)
* Run Command by Ctrl-Enter

This freeware can be downloaded at http://www.mymobiler.com/

Works great with Symbol handheld scanners with Windows Mobil 5

Saturday, August 21, 2010

Find out free disk space on SQL server

The xp_fixeddrives returns a list of physical hard drives associated with the SQL Server machine and the number of megabytes of free space on each one.

exec xp_fixeddrives

Wednesday, July 14, 2010

Convert all uppercase text to propercase in MS-Word.

1. Copy and paste all uppercase text in MS-Word.
2. Select all the text by pressing CTRL + A.
3. Press SHIFT + F3 to convert all text to lowercase.
4. Press SHIFT + F3 again to convert it to propercase.

Tuesday, June 22, 2010

T-SQL Format DateTime

Convert SQL DATE/Times to commonly used formats

-- Date Format MM/DD/YYYY
SELECT CONVERT(varchar(10),getdate(),101)

-- Date Fromat MM/DD/YYYY HH:MM

SELECT CONVERT(char(10), getdate(), 101)
+ ' ' + CONVERT (char(5), getdate(), 108);


SELECT CONVERT(VARCHAR, GetDate(), 101) + ' ' +
CONVERT(VARCHAR, DATEPART(hh, GetDate())) + ':' +
RIGHT('0' + CONVERT(VARCHAR, DATEPART(mi, GetDate())), 2) AS Date


SELECT CONVERT(CHAR(11),GETDATE(),101)
+ CONVERT(CHAR( 5),GETDATE(),114)


--- Date Format MM/DD/YYYY HH:MMAM/PM

SELECT CONVERT(VARCHAR(10), GETDATE(), 101) + ' ' + RIGHT(CONVERT(VARCHAR, GETDATE(), 100), 7)

Tuesday, May 25, 2010

Search and Replace in text column

You can not use T-SQL Replace function directly on a text field.

There are more complex ways to do this but if your filed size is < 8000 ( or <4000 for nvarchar), simple sql below may serve the purpose

UPDATE myTableSET set myField = REPLACE(SUBSTRING(myField, 1, DATALENGTH(myField)), 'searchText', 'replacementText') where DATALENGTH(myField) < 8000

Friday, April 30, 2010

Restoring SQL Server databases from .mdf files

USE master;
GO

-- first detach the exisitng databse if already exists

EXEC sp_detach_db @dbname = 'AdventureWorks';

-- attach .mdf file to the database
EXEC sp_attach_single_file_db @dbname = 'AdventureWorks',
@physname = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data\AdventureWorks_Data.mdf';