Saturday, August 19, 2017

How do you navigate between pages in a Single Page Application?

Here we are working with a Angular JS application.

Actually there are no 'Pages' in a Single Page Application (SAP) but no problem. If you are familiar with anchor tags in HTML, you could follow it with the help of the SRC's in your script that will help updating the page dynamically calling up the routing in AngularJS.

These are two important script references that you should add to your SPA:<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script><br /><script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script> 
This is an important module that makes routing possible:
ngRoute:

ngRoute module provides the routing and deep linking services and directives for a Angular JS applications.

You should read the documentation which gets clearer when you do an example.

ngRoute teams up with ngView directive to render the partial views.

ngView:
"ngView is a directive that complements the $route service by including the rendered template of the current route into the main layout (index.html) file. Every time the current route changes, the included view changes with it according to the configuration of the $route service."

Here is an example of a SPA hosted on my localhost (the file below is placed in the wwwroot directory of  C:\inetpub

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular-route.js"></script>

<body ng-app="HtekApp">
<h1>HODENTEK BOOKS</h1>
<p><a href="#/!">Welcome to Hodentek</a></p>

<a href="#!SSIS">SSIS </a>
<a href="#!SSRS">SSRS</a>
<a href="#!Azure">Azure SQL</a>


<div ng-view></div>

<script>
var app = angular.module("HtekApp", ["ngRoute"]);
app.config(function($routeProvider) {
    $routeProvider
    .when("/", {
        template : "Click on the link to see the contents"
    })
    .when("/SSIS", {
        template : "<h1>SQL Server Integration Serivces 2005"
    })
    .when("/SSRS", {
        template: "<h1>SQL Server Reporting Services</h1><h2>SSRS 2008: ISBN: </h2><h2>SSRS 2012: ISBN</h2>"
    })
    .when("/Azure", {
        template: "<h1>Microsoft SQL Azure Enterprise Application Development</h1>"
    });
});
</script>


</body>
</html>

The page renderings of the links are as shown:











Monday, August 14, 2017

Is SVG a part of HTML5?


SVG is variously described as  'part of HTML5 specification' or an HTML5 extension. In either case, I am very happy as I am a fan of SVG.

In HTML documents you could embed an in-line SVG code.
SVG in some cases appear superior to Canvas in HTML. SVG creates prefabricated graphics that is part of the documnet model which can be accessed by the ID for any event based action, where as the graphics for use in CANVAS needs to be created and rendered during page loading.

Read my SVG related posts here:

http://hodentekhelp.blogspot.com/2015/12/does-microsoft-edge-support-svg.html

http://hodentek.blogspot.com/2009/10/finally-svg-in-visual-studio.html

http://hodentek.blogspot.com/2010/09/svg-gets-rendered-on-ie-90.html

http://hodentek.blogspot.com/2013/08/short-of-cash-get-apache-openoffice-40.html

http://hodentek.blogspot.com/search?q=svg

http://hodentekmobile.blogspot.com/2016/03/intel-xdk-controls-2-usage-of-svg-and.html

Saturday, August 12, 2017

How do you enable database mail in SQL Server 2016?

For security reasons this feature is turned off and you must enable it.

In a newly installed server if you run stored procedure in the context of msdb

EXEC sp_send_dbmail

You get the following message:

'Msg 15281, Level 16, State 1, Procedure sp_send_dbmail, Line 0 [Batch Start Line 9]
SQL Server blocked access to procedure 'dbo.sp_send_dbmail' of component 'Database Mail XPs'
because this component is turned off as part of the security configuration for this server.
A system administrator can enable the use of 'Database Mail XPs' by using sp_configure.
For more information about enabling 'Database Mail XPs', search for 'Database Mail XPs' in
SQL Server Books Online.

'


This is how you enable Database Mail extended Procedure:
-----------
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Database Mail XPs', 1;
GO
RECONFIGURE
GO


---------------

----------

Now run this statement.

EXECUTE msdb.dbo.sysmail_help_status_sp

You get this response:


DatabaseMail_1.png

You will find the dbo.sp_send_dbmail stored procedure in the msdb database.


DatabaseMail_2.png

You will find all these objects in the msdb database in the Stored Procedures and Views nodes.


DatabaseMail_3.png

Thursday, August 10, 2017

How do I keep my email addresses and passwords encrypted using SQL Server?

You could keep your email addresses and passwords in SQL Server database table. You could get a free copy of your SQL Server from a Microsoft download site.

While the email addresses can be kept un-encrypted, you may want to keep your passwords in an encrypted column of a table. If want to keep everything encrypted you can do it also.

With this table set up correctly you may need to remember just one phrase which can be of your choosing.

Here are steps to create such a table:

1. Create a table in one of your existing databases. I am creating this table in a database called 'Aloha' which I use for teaching.

Here is the statement to create the table:

USE Aloha
Go
Create Table Encrpt(
emailID int Primary Key not null,
emailAdd nvarchar(25) null,
emailPswd varbinary(250) null
)


This creates the table ENCRPT.

The email password (emailPswd) is stored in a special column(varbinary data type) as shown above.

Now keep a list of emails and the passwords ready to populate the table.

Populate the table you created by inserting values using the following code:

INSERT INTO ENCRPT(emailID, EmailAdd, emailPswd)
values (1, 'hodentek@live.com', EncryptByPassPhrase('Happy birthday to you','xyzpo')),
(2, 'mysorian@gmail.com',EncryptByPassPhrase('Happy birthday to you ','ZZZ12$' )),
(3, 'htek@mysorian.com',EncryptByPassPhrase('Happy birthday to you','$$$11X' ))

I have inserted only three values but you could add more. While the email addresses shown are my real addresses, the passwords are not.

Now when you run a SELECT statement to display all the columns, this is what you see.


Here is a screen shot of all code:


I have used the same PassPhrase for all data, you could have different on, the onus of remembering phrases is on you.

The fourth row was filled using a different PassPhrase ('Happy Anniversary).
Read more here:

https://hodentekmsss.blogspot.com/2017/08/encrypting-email-password-in-sql-server.html

Tuesday, August 8, 2017

How do you launch Excel from SQL Server Management Studio?

I am using SQL Server Management Studio Version 17.1. You may user another version.

Launch SSMS 17.1

Click Tools | External Tools...

External Tools window is displayed as shown.



Replace the Title with a name of your own, herein Excel Application. The menu contents also
changes to the one you provided, herein Excel Application.

You need to provide the location of the executable in the Command box. In the present case the
executable is here:

"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"

Now you External Tools window should appear as shown.


Click OK.

Now you will find 'Excel Application' as shown in the Tools menu.


Now when you click this menu item, Excel Application is launched.


Tuesday, August 1, 2017

What is the difference between dbo and db_owner?

This question pops up now and then.

dbo is a user and db_owner is a database role. They both are in the Security node in the Object Browser. The SQL Server Management Studio (SSMS) makes it abundantly clear.

dbo



dbo.png

db_owner

db_owner.png

It will be instructive to review their properties as shown here.

dbo - Properties



dboProps.png

db_owner - Properties


db_ownerProps.png