Friday, 20 July 2018

SQL Update target tables from 2 different databases

begin transaction;

update [destination database].[dbo].[destination table] 
set [destination database].[dbo].[destination table].'destination column' = source.'desired column'
from [source database].[dbo].[source table] source
inner join [destination database].[dbo].[destination table] destnation 
on destination.'column to join' = source.'column to join'

--rollback; 
--commit; 


Wednesday, 4 July 2018

Vue.js Get Json Data and Display

Index.html
<html>
<title></title>
    <head>
        <!-- Import Vue library -->
        <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    </head>
    <body>
        <div id="app">
            <li v-for="msg in json">
                {{msg}}
            </li>
            <input v-model="text"/>
            <button @click="DisplayData">Query</button>
        </div>
    <script src="index.js"></script>
    </body>
</html>


Index.js
var app = new Vue({
    el: "#app",
    data: {
        text: "",
        json: null
    },
    methods: {
        DisplayData: function () {
            if (this.text)
            {
                fetch("https://api.github.com/users/" + this.text)
                    .then(r => r.json())
                    .then(json => { this.json = json; });
            }
        }
    }
});


Friday, 6 April 2018

Button feature not working within update panel in ASP.NET

To resolve this, initiate a full page postback trigger on update panel:

<asp:UpdatePanel runat="server">
    <Triggers>
        <asp:PostBackTrigger ControlID="YourControlID" />
    </Triggers>
    <ContentTemplate>
        .....


Wednesday, 14 February 2018

Call button on hit enter key in a text box

<script type="text/javascript">
    function ApplyFilterOnEnterKey(e) {
        if (e.keyCode == 13) {
            document.getElementById("_ctl0:mainContent:Search").click();
            return false;
        }
    }
</script>


Add the following attribute to the textbox:
onkeypress="return ApplyFilterOnEnterKey(event)"


Thursday, 18 January 2018

Windows 10 StopCode - Rebooting on Startup

Windows 10 StopCode - Rebooting on Startup and cannot restore, re-install, etc. To fix this issue:
  • Boot from a bootable media
  • On start-up, go to Troubleshoot, Advance options, and open the Command Prompt
  • Change the drive to Windows drive
  • Issue the following commands:
    • cd windows\system32\config
    • md backup
    • copy *.* backup
    • cd regback
    • copy *.* ..

Than exit and restart the system... more


Wednesday, 17 January 2018

Create PDF from HTML using NReco.PdfGenerator with page number

var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
htmlToPdf.PageFooterHtml = @"<div style='text-align:right; font-size:14px;'>Page <span class=""page""></span> of &nbsp;<span class=""topage""></span><div>";
htmlToPdf.Margins.Top = 15;
htmlToPdf.Margins.Bottom = 15;
htmlToPdf.Margins.Left = 8;
htmlToPdf.Margins.Right = 8;

var pdfBytes = htmlToPdf.GeneratePdf(HtmlFile);
File.WriteAllBytes(newpath, pdfBytes);


Thursday, 28 December 2017

1. Download MongoDB from here
2. Install the MongoDB using "Custom" and set the path to C:\MongoDB
3. After install is completed, open "Command Prompt" as "Administrator"
4. Issue the following command to create folder for databases and logs
    C:\MongoDB>md log
    C:\MongoDB>md data\db
5. Navigate to C:\MongoDB\Bin and run the following command
    mongod --directoryperdb --dbpath C:\MongoDB\data\db --logpath C:\MongoDB\log\mongo.log --logappend --rest --install
6. Run the service:
  C:\MongoDB\Bin>net start MongoDB
7. Type "mongo.exe" to open the shell
8. Useful commands:
cls : clear screen
show dbs : show the list of databases
use customers : create database 'customers' and switch to it
db : give the current database name
9. Assign role to database
db.createUser ({
user: "admin",
pwd: "admin",
roles: ["readWrite","dbAdmin"]
    });


MongoDB manual and reference: click here
MongoDB Download centre: click here


Analysis Service in Power BI Report Server

 We couldn’t connect to the Analysis Services server. Make sure you’ve entered the connection string correctly... link