Wednesday, January 10, 2018

VS project "Optimized Code" :: Cannot obtain value of local or argument as it is not available at this instruction pointer

While debugging an existing code in VS 2015 tried to "watch" a couple of variables and encountered with below message without showing the values:
"Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away"

To fix it and get rid of optimization to be able to see the values and also keep debugging in steps without jumping between lines because of optimized code then I unchecked the [Optimize Code]:

Project Properties --> under Build --> Unchecked the [Optimize Code] checkbox.
In the Advanced Options in the project build tab, I set the the "Debug Info" combo to "Full".

Share/Bookmark

Tuesday, January 9, 2018

The database principal owns a schema in the database, and cannot be dropped

SQL Error: "The database principal owns a schema in the database, and cannot be dropped" To fix the issue, we need to find out the userId is owned which schema(s).
SELECT name FROM sys.schemas WHERE principal_id = USER_ID('theUserName')

Then you can assign the schema(s) to dbo to release the user from owning them.
ALTER AUTHORIZATION ON SCHEMA::SchemaName TO dbo


Share/Bookmark

Thursday, December 21, 2017

How to check if a web by its' url is up and running by Powershell

function IsTheWebUrlUp { try { Invoke-WebRequest -Uri $webUrlLocation -UseBasicParsing ` -UseDefaultCredential | Select-Object StatusDescription ` | Tee-Object -Variable isWebUp | Out-Null; return $isWebUp.StatusDescription -eq "OK" } Catch { write-host "Caught an exception:" -ForegroundColor Red write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red return $false; } }

Share/Bookmark

Wednesday, June 7, 2017

JavaScript code to show image from raw image content bytes (blob)

<div> <img id="attachmentImage" /> </div> // attachmentCntnt : this variable contains raw bytes array of the attachment image // attachmentType : keeps the image type such as jpg/jpeg/png/... // _.defer and _.isNull are methods from underscore.js library var imageUrl = null; var attachmentCntntU8Ary = new Uint8Array(attachmentCntnt); var blob = new Blob([attachmentCntntU8Ary], { type: "image/" + attachmentType }); var urlCreator = window.URL || window.webkitURL; imageUrl = urlCreator.createObjectURL(blob); _.defer(function (t) { if (!_.isNull(imageUrl)) { var img = document.querySelector("#attachmentImage"); img.src = imageUrl; }; }, self);

Share/Bookmark

Sunday, June 4, 2017

Angular 4.0 + Angularfire 2 Ver 4.0 RC2 :: ERROR in ./~/firebase/app/shared_promise.js

"dependencies": { "@angular/common": "^4.0.0", "@angular/compiler": "^4.0.0", "@angular/core": "^4.0.0", "@angular/forms": "^4.0.0", "@angular/http": "^4.0.0", "@angular/platform-browser": "^4.0.0", "@angular/platform-browser-dynamic": "^4.0.0", "@angular/router": "^4.0.0", "angularfire2": "^4.0.0-rc.0", "core-js": "^2.4.1", "firebase": "^4.0.0", "rxjs": "^5.1.0", "zone.js": "^0.8.4" },

Angular 4.0 + Angularfire 2 Ver 4.0 RC2 :: ERROR in ./~/firebase/app/shared_promise.js promise-polyfill It's about missing dependenciy which could be fixed by installing promise-polyfill by npm.
npm install promise-polyfill --save-exact

Share/Bookmark

Wednesday, November 23, 2016

Uninstall "Angular 2 CLI "

:: To get version of the already installed Angular 2 CLI ::
ng -v

:: Uninstall the existing Angular 2 CLI ::
npm uninstall -g angular-cli npm cache clean npm install -g angular-cli@latest

Share/Bookmark

Angular 2 CLI

Angular 2 CLI
:: Installation ::
npm install -g angular-cli

:: Create and run a working Angular 2 app ::
ng new PROJECT_NAME cd PROJECT_NAME ng serve

:: Up and running :: Navigate to http://localhost:4200/
Share/Bookmark

Monday, September 19, 2016

ASP.NET Telerik Combo Box control issue with backspace

<telerik:RadComboBox runat="server" ID="RadComboBox1" AllowCustomText="true" EmptyMessage="" Width="85%" EnableEmbeddedSkins="false" DataTextField="Code" DataValueField="Id" RenderMode="Lightweight" ToolTip="Impact is Required" MarkFirstMatch="True" OnClientLoad="window.utility.Cbo.onClientLoad">

JS code part:
(function () { 'use strict'; //The namespace window.utility = window.utility || {}; // ComboBox window.utility.Cbo = window.utility.Cbo || {}; window.utility.Cbo.onClientLoad = function (sender) { $telerik.$("#" + sender._inputDomElement.id).on('keyup', function (e) { if (e.keyCode == 8) { var combo = $find(sender._uniqueId.split('$').join('_')); if (!combo || !this.selectionStart || this.selectionStart <= 0) return; var caretPosition = this.selectionStart var comboText = combo.get_text(); if (comboText || comboText.length > 0) { var newComboText = comboText.slice(0, caretPosition - 1) + comboText.slice(caretPosition); combo.set_text(newComboText); --caretPosition; this.selectionStart = (caretPosition < newComboText.length) ? (caretPosition >= 0) ? caretPosition : 0 : newComboText.length - 1 this.selectionEnd = this.selectionStart; } } }) } })();

Share/Bookmark

Friday, December 18, 2015

Oracle SQL Developer Keyboard Shortcuts by thatjeffsmith - Cheatography.com: Cheat Sheets For Every Occasion

Oracle SQL Developer Keyboard Shortcuts by thatjeffsmith - Cheatography.com: Cheat Sheets For Every Occasion
Share/Bookmark

Monday, November 16, 2015

Javascript String.padLeft( len, leadingChar )

String.prototype.padLeft = function padLeft(length, leadingChar) { if (leadingChar === undefined) leadingChar = "0"; return ( this.length < length ) ? (leadingChar + this).padLeft(length, leadingChar) : this; };

Share/Bookmark

Tuesday, September 22, 2015

FIX: Poor performance when you use table variables in SQL Server 2012 or SQL Server 2014 :: KB2952444

The performance issue with Table variables with many rows and then join it with other tables has ben fixed by as explained in KB2952444. Before the fix which applied to SQL Server 2012 SP2 and later, the query optimizer may choose an inefficient query plan, which may lead to slow query performance.

https://support.microsoft.com/en-us/kb/2952444

Share/Bookmark

Tuesday, September 15, 2015

AngularJS Style Guide by John Papa


AngularJS Style Guide by John Papa
https://github.com/johnpapa/angular-styleguide

Share/Bookmark

T-sql :: Change just DATE part of a DATETIME

DECLARE @dt DATETIME SET @dt = GETDATE() SELECT DATEADD(dd, DATEDIFF(dd, @dt, '2015-06-01'), @dt)

Share/Bookmark

Tuesday, July 7, 2015

Set date to first day of the month and end day of the month

Set date to first day of the month:
SELECT DATEADD(m, DATEDIFF(m, 0, GETDATE()), 0)

Set date to end day of the month:
SELECT EOMONTH(GETDATE())

Set date to last day of the previous month:
SELECT EOMONTH(GETDATE(), -1)

Remove milliseconds from datetime:
DECLARE @now DATETIME SET @now = GETDATE() SELECT @now SELECT DATEADD(ms, -DATEPART(ms, @now), @now)

Share/Bookmark

Friday, February 27, 2015

Visual Studio Error List and Output Window shortcuts

To view the Error List window: CTRL + \,E inside the IDE.
To show the Output Window: CTRL + ALT + O.

Share/Bookmark

Wednesday, February 11, 2015

Visual Studio Immediate Window shortcut

To get in the immediate window in Visual studio ::
Debug --> Windows --> Immediate
Ctrl + Alt + I
Share/Bookmark

Monday, September 8, 2014

Unable to update the EntitySet ‘Table’ because it has a DefiningQuery and no element exists in the element to support the current operation

Entity Framework tried to add a record to a table which had Clustered Index but it didn't have Primary Key.

Simple solution was adding the Primary Key.

the reason is treating the table as View, then the EDMX file keep the table as a view in StorageModel\EntitySet\DefiningQuery element. When there is a DefiningQuery the Entity becomes readonly unless you add modification functions, the other solution can be adding modification functions like Stored Procedures for Inserting, Updating, and Deleting.

Share/Bookmark

Tuesday, August 19, 2014

VS :: Peek Definition

Everyday I enjoy the Peek definition in Visual Studio 2013 !

Share/Bookmark

Friday, June 27, 2014

SQL - Break execution of a SQL script

SET NOEXEC ON

SET NOEXEC ON skips the rest of the script but it does not terminate the connection.
To execute any other command you need to turn noexec off again.

OR

RAISERROR('Your error message', 20, -1) WITH log

This will terminate the connection, thereby stopping the rest of the script from running.
If you are logged in SQL as [admin] ('sysadmin' role), the RAISERROR will terminate the connection and stops the script from running the rest of code.
(If you are not logged in as [admin], otherwise the RAISEERROR() will fail and the script will continue executing.) Note that it requires both severity 20 (or higher) and "WITH LOG".

Share/Bookmark

Recursive SQL CTE to split CSV string to table rows

DECLARE @strCSV VARCHAR(8000) , @delimiter CHAR(1) SET @delimiter = ',' SET @strCSV = '001002330 ,001012657 ,001046228 ,001105047 ,001138189' DECLARE @TableVariable TABLE ( ID INT, Item VARCHAR(12) ) ;WITH RegNumStartEndIndexes AS( SELECT StartIndex = 0 , EndIndex = CHARINDEX(@delimiter,@strCSV) UNION ALL SELECT EndIndex+1 , CHARINDEX(@delimiter,@strCSV,EndIndex+1) FROM RegNumStartEndIndexes WHERE EndIndex>0 ) INSERT INTO @TableVariable (ID, Item) SELECT ROW_NUMBER() OVER(ORDER BY(SELECT 1)) AS ID , REPLACE( REPLACE( SUBSTRING(@strCSV, StartIndex, COALESCE(NULLIF(EndIndex,0), LEN(@strCSV)+1)-StartIndex), CHAR(13), ''), CHAR(10), '') AS Item FROM RegNumStartEndIndexes option (maxrecursion 0) -- [option (maxrecursion 0)] added To avoid following error when number of recursions gets high -- The maximum recursion 100 has been exhausted before statement completion SELECT * FROM @TableVariable

Originally grabbed the idea from here

Share/Bookmark