Wednesday, February 27, 2019

SQL RAISEERROR and Log the error

Put all SQL Stored Procedures in BEGIN TRY > BEGIN TRANSACTION > IF  ELSE blocks and use the following as a TEMPLATE

Create an output parameter so the source code can log the error and you can check the DB table for the error.


@ELog_ID int = 0 OUTPUT 

SET XACT_ABORT, NOCOUNT ON;

BEGIN TRY
BEGIN TRANSACTION


IF
            IF EXISTS (SELECT 'x' FROM People_tbl WHERE Email_Address = @Email_Address)
RAISERROR (N'Person is already in the database.',11,11, 'usr_Person_Add')
--PRINT 'Person is already in the database!'

ELSE

-- CRUD work

END TRY

BEGIN CATCH

--PRINT 'In the Catch Statement'
IF @@trancount > 0 ROLLBACK TRANSACTION
PRINT 'Process has reached the CATCH'

EXECUTE dbo.[usr_InsertErrorInfo];

SELECT @ELog_ID = max(ELog_ID)
FROM ErrorLog_tbl;


END CATCH


Tuesday, February 26, 2019

PowerShell output to table and text file

Get-SPUser -Web "https://subdomain.domain.com" | format-table -autosize > e:\spusers.txt

https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-6

Monday, January 07, 2019

Azure Cost Learning from Experience after Free Trial Expires

Well, today I logged into my Bank account and I have I nice debit of "MSFT AZURE", although I thought I was very careful to turn off all the Apps/Slots I would not be charged.







https://azure.microsoft.com/en-us/pricing/details/app-service/windows/

Another lesson by experience, I was wrong if you have a Plan aka S1 you will be charged even if you do not have one service running.



Set-AzureRmAppServicePlan -ResourceGroupName $rg -Name $AppServicePlan -Tier Free

RoboCopy

Robocopy command can be used to move data from one folder to another.
example:
Go to cmd
Robocopy "C:\SourceDir" "C:\DestDir" /E

above command copies all folders, subfolders and files from source to destination folder.
Happy Learning!

Read more about this here:
https://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx

/MIR option. It can intelligently mirror source and destination, copying ONLY changed files and deleting files on the destination that are no longer on the source. Very useful when you need to maintain a backup/standby system. rsync is the unix equivalent to this command. I used rsync at home just yesterday. Great stuff!

Wednesday, December 19, 2018

Microsoft Word Navigation Pane (Keep It Open - TOC)

To get to the Microsoft Word Navigation click ctrl+f then select navigation pane and leave it open while working on a very long document.   It will help you from pulling out your hair.

Friday, November 02, 2018

JavaScript Execution

1) Global Memory 2) Global Execution 3) Call Stack Tatoo it on my arm. Be a JavaScript Master mind --- JavaScript is Single Threaded. function myFunc(){ Console.write("Hello Moojjoo Blogger"); } That function will never run unless it is called. It is stored in the Global Memory, but will never execute unless you call myFunc(); Aka Functions, Executions, Contexts and Call Stack... Know that and JavaScript will be easy for you.

Monday, October 08, 2018

How to delete or clear authentication, cache, and cookies

Instead of trying to hunt down cookies to delete or clear cache for images, authentication, etc. etc. Simply use a Chrome Incognito or Edge new private window. Brand new fresh clean browser window.

Tuesday, October 02, 2018

.NET Core 500 Exception how to see your errors

If you are developing using .Net Core be sure to set the final Configure to the following and be sure to use your keyboard short cut alt+enter to bring in the missing using namespaces for your references needed. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { env.EnvironmentName = EnvironmentName.Development; if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/error"); } app.UseStatusCodePages(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); c.RoutePrefix = string.Empty; }); app.UseMvc(); } }