Wednesday, August 28, 2013

How to change Oc-admin folder in Osclass?

First Change the name of oc-admin folder. 
Then change the following variable
 $path .= "oc-admin/"; to your desired name in osc_admin_base_path and osc_admin_base_url functions. But it should be same as the name of your folder that you changed. 
osc_admin_base_path and osc_admin_base_url both defined on oc-includes/osclass/helpers/hDefines.phpThat's the best and easiest way to do it.

How to read a file into byte array in asp net C# or VB?

Just use
System.IO.File.ReadAllBytes(filename);

Tuesday, August 27, 2013

How to check if column was modified using trigger in sql server

CREATE TRIGGER dbo.haschanged --Any Trigger name
ON [table]
after UPDATE
AS
  BEGIN
      SET nocount ON;

      DECLARE @Old VARCHAR(100),
              @New VARCHAR(100)

      SELECT @New = i.[col]
      FROM   inserted AS i

      SELECT @Old = d.[col]
      FROM   deleted AS d

      IF @New <> @Old
        BEGIN
            --Field was changed
            
        END
      ELSE
        BEGIN
            --Field was not changed
           
        END
  END 

OR
CREATE TRIGGER dbo.haschanged --Any Trigger name
ON [table]
after UPDATE
AS
  BEGIN
      IF UPDATE (col)
        BEGIN
            --Field was changed
            
        END
      ELSE
        BEGIN
            --Field was not changed
           
        END
  END 

Insert / Update image into SQL Server database using query (not front end application)

Using Insert

INSERT INTO [table]
            (COLUMN)
SELECT *
FROM   OPENROWSET(BULK N'Path to file', single_blob) AS [File] 


Using Update

UPDATE [table]
SET    [column] = (SELECT *
                   FROM   OPENROWSET(BULK N'Path to file', single_blob) AS
                          [File])
--Conditions if any

Monday, August 26, 2013

Hide custom errors asp net

<configuration>
    .......
    <system.web> 
        ......
        <customErrors mode="Off"/>
    </system.web>
</configuration>
 
Note: "mode values are case sensitive" 

jQuery how to check html input checkbox state

$("input[type=checkbox]").change(function () {
     var isChecked = this.checked;
     if (isChecked) {
          //rest goes here
     }
});

How to check if a string is null or empty (length 0) sql server

First convert empty value to null using "nullif" then use "isnull" to switch
SELECT Isnull(NULLIF(string1, ''), string2) AS String .......

Sunday, August 25, 2013

How to Install Softaculous on VPS or Dedicated Server with cPanel/WHM?

1. cd /usr/local/cpanel/whostmgr/docroot/cgi
2. wget -N http://www.softaculous.com/ins/addon_softaculous.php 
3. chmod  755 addon_softaculous.php 
4. /usr/local/cpanel/3rdparty/bin/php addon_softaculous.php

How to limit export formats in crystal reports


CrystalReportViewer.AllowedExportFormats = 
(int)CrystalDecisions.Shared.ViewerExportFormats.PdfFormat

Wednesday, August 21, 2013

How to scan a website for bugs using backtrack

http://www.hackforsecurity.net/2013/07/how-to-scan-website-for-bugs-using_14.html

CSS 3 Gradient Editor

Color Zilla Gradient Editor
http://colorzilla.com/gradient-editor/

Compare files online

Diff Now
http://www.diffnow.com/

Replace / Remove a newline or carriage return in T SQL

REPLACE({String}, CHAR(13)+CHAR(10), '')
Source:http://stackoverflow.com/questions/951518/replace-a-newline-in-tsql

Get size of all tables in database sql server

SELECT s.name AS SchemaName
 , t.NAME AS TableName
 , p.rows AS RowCounts
 , FORMAT(SUM(a.total_pages) * 8 / 1024.0, 'N2') AS TotalSpaceMB
 , FORMAT(SUM(a.used_pages) * 8/ 1024.0, 'N2') AS UsedSpaceMB
 , FORMAT((SUM(a.total_pages) - SUM(a.used_pages)) * 8 / 1024.0, 'N2') AS UnusedSpaceMB
FROM sys.tables t
INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID
 AND i.index_id = p.index_id
INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
WHERE t.NAME NOT LIKE 'dt%'
 AND t.is_ms_shipped = 0
 AND i.OBJECT_ID > 255
GROUP BY s.name
 , t.Name
 , p.Rows
ORDER BY p.Rows DESC