February 22, 2016

[Android] Fast ADB installer


If you need just the adb tool for debugging your mobile app, but you don't need the whole big size SDK, use this tool : Download 15 seconds ADB Installer v1.3

Features:
Small - 9.18 MB
Fast - 15 seconds install
Include - ADB, Fastboot and also Drivers
Easy to install - just run it and program will guide you
Clean - ADB and Google Drivers from latest SDK

Install process:
1. Run it with administrator privileges
2. Press Y/Yes to install ADB and Fastboot or N/No to skip
3. Press Y/Yes to install ADB system-wide or N/No for current user only
4. Press Y/Yes to install Drivers or N/No to skip
5. Continue Driver installation
6. 15 seconds passed - finished!

Notes:
System-wide: ADB and Fastboot are installed to %SystemDrive%\adb directory, and added system-wide path.
Current user only: ADB and Fastboot are installed to %UserProfile%\adb directory, and added path for current user.
CMD can use ADB and Fastboot from any directory.
Drivers are installed to system - no need to install them from directories.
Installer automaticly decides if install 32-bit or 64-bit drivers.
If you have problem with driver enumeration in Windows 8.1 install update KB2917929

February 19, 2016

[SQL] Good practice in writing scripts for Table and Stored Procedures

I learned this from my current project's team leader, Shaun who is a good programmer himself. His attentive to details is off the chart among those that I know. These are good habits to incorporate into my programming skill, specifically for SQL.

All the tips below are to ensure that our SQL scripts can be executed at all times and multiple times. These are also to ensure that MOST preconditions are covered so that our script can be executed successfully until the end of the line - instead of stopping halfway due to errors.. Sometimes, we as developer have no control over the deployment of our scripts. Once we handed them over, the IT guys of the clients will run the scripts and chase us when something goes wrong (which happens, all the time!)



For TABLES

1. To create a new table, do not just DROP and CREATE. The best way is to put in the preconditions check, that is to check first IF EXIST (using schema, sys,object or HASH and then DROP. This will avoid stopping the execution of the script due to the table not found - thus can't be dropped.

Using sys,objects :

IF EXISTS(SELECT 1 FROM sys.Objects WHERE  Object_id = OBJECT_ID(N'dbo.MY_TABLE') AND Type = N'U')
BEGIN
PRINT 'TABLE_EXIST'
ENDIF 

Using Hash :

IF DBO.getTableHash('MY_TABLE') = 0xACE31E3C4550DE4B166F01E78A1D86E5
  DROP TABLE MY_TABLE

2. To insert a new data, ensure that ALL PRIMARY KEYS of the rows are checked against before the INSERT command is executed. This is to ensure that we select exactly the data row that we want - the use of Primary Keys distinguishes this!

IF NOT EXISTS (SELECT * FROM TABLE1 WHERE COL_PK1='A1' AND COL_PK2='A2') 
BEGIN
INSERT INTO SET_INITIAL 
(COL3, COL4)
VALUES 
('A3','A4')
END


For STORED PROCEDURES (StoProc)

1. To alter an existing StoProc or to create a new one, do not use DROP and CREATE. SQL keeps a log somewhere with regards to the creation and modification of any StoProc. For existing StoProc, DROP and CREATE will not be helpful anymore for the logs because CREATE builds a new StoProc altogether instead of referring to the previously existing one that being dropped. Instead, use the following : Check IF NOT EXIST, then CREATE empty StoProc. Then, followed by ALTER StoProc. In the above script, first part creates an dummy StoProc if the StoProc with the specified name in the specified schema does not exist. This is useful for the initial setup, when you are creating this StoProc in a new environment. The second part alters the StoProc always – whether it’s created in the first step or it existed before. So, every time you need to make some changes in the StoProc, only the ALTER PROCEDURE section (second part) of the above script needs to be modified and entire script can be executed without worrying whether the StoProc already exists or not.

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[SP_MY_ELEGANT_SP]') AND type in (N'P', N'PC'))
 EXEC('CREATE PROCEDURE [dbo].[SP_MY_ELEGANT_SP]  AS SET NOCOUNT ON;')
GO

ALTER PROCEDURE [dbo].[SP_MY_ELEGANT_SP]
.....

The usual approach what people follow for modifying StoProc is to check IF EXIST, then DROP it (if exists) and CREATE it back. The following are the drawbacks of using this approach:

  • Permissions associated with the object, like GRANT EXECUTE etc., are lost when we DROP and CREATE the StoProc.
  • If ALTER PROCEDURE is used on any prior version in a "maintenance" script, different Script needs to be written to cater for it if the StoProc is already existed.
  • If DROP PROCEDURE and CREATE PROCEDURE approach is used, then all the permissions previously present on the Stored Procedure need to be given again with the help of necessary additional scripts. 


[SSRS] Missing URL parameter: IterationId

Your SSRS report previewed well on Visual Studio but when publishing it, you were prompted with the following error:

Error caught in Application_Error event:
Microsoft.Reporting.WebForms.HttpHandlerInputException: Missing URL parameter: IterationId

To go around this, add your site to "Compatibility View Setting" of your Internet Explorer and voila!



February 5, 2016

[SSRS] Clear Report Data Cache easily

Some changes on your SSRS report weren't being reflected when you run it, especially when you made changes on the SP.

Why? SSRS kept a data cache file of the report when you first ran it. By running the report again, sometimes SSRS only retrieves the data cache file instead of actually running the report entirely again. I think this is only the case when you made changes structurally (getting new data column, maybe?) on your SP.

Let's create a shortcut to remove these files :

Go to Tools > External Tools

Add a new tool with the following settings:

      Title: Clear Report Data Cache
Command: "%WinDir%\System32\cmd.exe" Arguments: /C DEL /S /Q "$(SolutionDir)\*.rdl.data"
Check options: Use Output window & Close on exit

Now you can run it. Just to Tools > Clear Report Data Cache 

You can check the output window



Credit Jason Faulkner