Query SQL Server Version

select
SERVERPROPERTY('ProductVersion') as ProductVersion,
SERVERPROPERTY('ProductLevel') as ProductLevel,
SERVERPROPERTY('Edition') as Edition

Server 2012 RDS ‘there are no Remote Desktop License Servers available to provide a license.’

http://www.stopdoingitwrong.co.uk/server-2012-rds-there-are-no-remote-desktop-license-servers/



You verify your configuration is as expected, that you have valid CALs installed on a Server 2012 terminal server licensing server and that the RD Licensing Diagnoser doesn’t report any errors.
The issue may be that there is a bug with Server 2012 RDS session hosts where they will not look to the licensing server for CALs when the grace period ends. Microsoft are reportedly aware of this but as yet there is no KBA or hotfix for it.
The solution is to open the registry editor on the affected session hosts and browse to the following:
HKLM\System\CurrentControlSet\Control\Terminal Server\RCM
If the ‘GracePeriod’ key exists you will need to delete it.

How can an unauthenticated user access a windows share?

http://serverfault.com/questions/51635/how-can-an-unauthenticated-user-access-a-windows-share


In my case, enabling the guest account and adding Everyone did not help (with a share on an older box with Windows Server 2008 SP2 in a domain and a Windows Server 2012 R2 machine from outside of the domain).
After following the excellent guide posted by Nikola Radosavljevic, anonymous access finally worked in my scenario.
Summary of steps:
  • Adding Everyone, Guest and ANONYMOUS LOGON to the permissions of the share.
  • Open the Group Policy Editor (e.g. by running gpedit.msc)
    • Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options
    • Accounts: Guest account status: Enabled
    • Network access: Let Everyone permissions apply to anonymous users: Enabled
    • Network access: Restrict anonymous access to Named Pipes and Shares: Disabled
    • Network access: Shares that can be accessed anonymously: YOUR_SHARE_NAME

Windows 10 Cannot Access SMB Network

1. https://www.itechtics.com/enable-gpedit-windows-10-home/



2. https://techjourney.net/cannot-connect-to-cifs-smb-samba-network-shares-shared-folders-in-windows-10/

SQL data Type to C# data Type

http://stackoverflow.com/questions/425389/c-sharp-equivalent-of-sql-server-datatypes

SQL CLR types for Report Viewer 2012 -Error







Install SQL CLR types & Report Viewer 2012 on Sql 2008 server


http://serverfault.com/questions/465722/install-sql-clr-types-report-viewer-2012-on-sql-2008-server

Troubleshooting: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel...'

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
This error can occur when there are multiple versions of the .NET Framework on the computer that is running IIS, and IIS was installed after .NET Framework 4.0 or before the Service Model in Windows Communication Foundation was registered.

For Windows 7 and Windows Server 2008, use the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) to register the correct version of ASP.NET. For more information about the aspnet_regiis.exe, see ASP.NET IIS Registration Tool.

To register the correct version of ASP.NET

  1. On the computer that is running Microsoft Dynamics NAV Web Server components, open a command prompt as an administrator as follows:
    1. From the Start menu, choose All Programs, and then choose Accessories.
    2. Right-click Command Prompt, and then choose Run as administrator.
  2. At the command prompt, type the following command to change to the Microsoft.NET\Framework64\v4.0.30319 folder, and then press Enter.
    cd\Windows\Microsoft.NET\Framework64\v4.0.30319
    
  3. At the command prompt, type the following command, and then press Enter.
    aspnet_regiis.exe -iru
    

Font Size Decreases When Export to PDF in Crystal Report

If barcode size is not what you expect when export to PDF in Crystal Report, you need to look no further for solution.

To fix the bug, just follow steps below by adding 2 registry keys.

1. Select Start > Run. Type regedit and click OK.

2. For Crystal Reports 2008, Expand HKEY_CURRENT_USER\Software\Business Objects\Suite 12.0\Crystal Reports\Export.

For Crystal Reports 11.0, Expand HKEY_CURRENT_USER\Software\Business Objects\Crystal Reports.

For Crystal Reports 10.0, Expand HKEY_CURRENT_USER\SOFTWARE\Crystal Decisions\10.0\Crystal Reports\Export

For Crystal Reports 9,0, Expand HKEY_CURRENT_USER\software\crystal decisions\9.0\Crystal Reports\Export

3. Right-click the Export folder and select New > Key. This creates a new folder. Name the new folder PDF.

4. Right-click the PDF folder and select New > DWORD Value.

5. Name this 'ForceLargerFonts' with no quotes and note that it is case sensitive.

6. Double-click ForceLargerFonts and change the Value data to 1 and click OK.

7. Close all the registry folders and expand the following registry For Crystal Reports 2008, HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 12.0\Crystal Reports.

For Crystal Reports 11.0, HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.0.

For Crystal Reports 10.0, HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.0\Crystal Reports

For Crystal Reports 9.0, HKEY_LOCAL_MACHINE\Software\Crystal Decisions\9.0\Crystal Reports

8. Right-click the Crystal Reports folder and select New > Key. Name this key Export.

9. Right-click the Export folder and select New > Key. This creates a new folder. Name this folder PDF.

10. Repeat steps 4 through 6.

11. Close the Registry Editor and restart Crystal Reports.


After adding these two registry keys, Crystal Reports won't have this font size problem any more.


However, if you want to generate barcode in Crystal Reports from IIS server, you need to modify permissions of these registry keys.

IIS security model prevents the application pool identity to read those registry entries by default.

Open Windows application Regedit and browse to

HKEY_LOCAL_MACHINE\SOFTWARE\Business Objects\Suite 12.0\Crystal Reports\Export\PDF

Right click the key and choose “Permissions” from context menu.

Add in default IIS user account. Usually it's IUSR_MachineName.

How to solve Microsoft.Jet.OLEDB.4.0 and Microsoft.ACE.OLEDB.12.0 problem IIS 7, IIS 8


https://www.microsoft.com/en-us/download/confirmation.aspx?id=23734

Excel data export to SQL database

'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine Error


Download and install the following link,


https://www.microsoft.com/en-us/download/details.aspx?id=23734

Public key authentication using Cygwin

Public key authentication using Cygwin


Overview

Enabling public key authentication allows us to seamlessly, without having to interactively enter credentials, perform the following tasks...

  • scp files from one host to another
  • Execute commands on remote host
  • Log on to remote host
The Cygwin sshd server runs as a Windows service under the Local SYSTEM account created with special privileges to run the service. For a Windows 2003 Server, sshd runs under local account, sshd_server. The sshd server authenticates user logins using a public/private key-pair.

Configure Cygwin sshd

In this example, we configure password-less public key authentication to a remote Worklight host. We will leverage a user named "WorklightAdmin"


  1. Install Cygwin.During installation, select the following packages...

    • Admin --> cygrunsrv
    • Net --> openssh
  2. After installation, edit...
      C:\cygwin\Cygwin.bat
    ...add the following line...

      set CYGWIN=binmode ntsec
    For example...

      @echo off

      C:
      chdir C:\cygwin\bin
      set CYGWIN=binmode ntsec
      bash --login -i
  3. Start a Cygwin terminal using "Run as Administrator"
  4. Verify Cygwin is installed property...
      cygrunsrv -h
    All Cygwin help options should display on the screen.
  5. From a bash shell, configure SSH...
      ssh-host-config
    You are prompted to answer the following questions:

      *** Query: Should privilege separation be used? : yes
      *** Query: New local account 'sshd'? : yes
      *** Query: Do you want to install sshd as a service?
      *** Query: : yes
      *** Query: Enter the value of CYGWIN for the deamon: [] binmode ntsec
      *** Query: Do you want to use a different name? (yes/no) yes/no
    At this point, for our example, we enter yes, and then plug in our WorklightAdmin user name and password...

      *** Query: Enter the new user name: WorklightAdmin
      *** Query: Reenter: WorklightAdmin
      *** Query: Create new privileged user account 'WorklightAdmin'? (yes/no) yes
      *** Query: Please enter the password:
      *** Query: Reenter:
    If the configuration is successful, you will see the following message:

      Host configuration finished. Have fun!
  6. If you ever want to change the login ID of the Cygwin sshd service afterwards...

    1. Open the Services panel
        Windows Start | Administrative Tools | Services
    2. Stop the sshd service.
        Cygwin sshd (right-click) | Properties | General | Stop
    3. Next, select the Log on tab. Under the Log on as section or prompt, clear the Local System account radio button, and select This account.
    4. Type .\WorklightAdmin as the ID and type the password for the account. Click Apply.
  7. Grant additional rights to the WorklightAdmin account. Ensure that the account has the required privileges in addition to membership to the Administrators group.


    1. From the Windows Start menu, click...
        Settings | Control Panel | Administrative Tools | Local Security Policy | Local Policies | User Rights Assignment
    2. Verify the WorklightAdmin account has the following four rights:
      • Adjust memory quotas for a process
      • Create a token object
      • Log on as a service
      • Replace a process level token
      If not, add WorklightAdmin as a user with the four rights.
  8. Close the Local Security Settings window.
  9. From a Cygwin console panel, change ownership of the following directories and files to WorklightAdmin:
    • chown WorklightAdmin /var/log/sshd.log
    • chown -R WorklightAdmin /var/empty
    • chown WorklightAdmin /etc/ssh*
  10. Restart the Cygwin sshd service.
      Cygwin sshd service | Properties | General | Start
    ...or...

      cygrunsrv -S sshd
  11. To achieve a password-less login from HostA --> remoteWLhost

    1. Login to HostA as user WorklightAdmin
    2. Copy contents of...
        $HOME/.ssh/id_rsa.pub
      If .ssh/id_rsa.pub does not exist, run..

        $ ssh-keygen -t rsa
        Generating public/private rsa key pair.
        Enter file in which to save the key (/usr/local/wasuser/.ssh/id_rsa):
        Enter passphrase (empty for no passphrase):
        Enter same passphrase again:
        Your identification has been saved in /usr/local/wasuser/.ssh/id_rsa
        Your public key has been saved in /usr/local/wasuser/.ssh/id_rsa.pub
        The key fingerprint is:
        05:db:12:51:9f:48:dc:43:cd:8f:22:b0:a7:47:2d:17 wasuser@hostname
      Leave passphrase blank.
    3. Log on to remote host (remoteWLhost) and paste the public key to...
        $HOME/.ssh/authorized_keys
      If the directory and/or file do not exist, create them.
    4. Set permissions...
        chmod go-w $HOME $HOME/.ssh
        chmod 600 $HOME/.ssh/authorized_keys
        chown `whoami` $HOME/.ssh/authorized_keys
  12. You can now run commands such on HostA such as...
      $ ssh -l WorklightAdmin remoteWLhost 'ls /cygdrive/c/path/to/Worklight/logs'
      console.log
      ffdc
      messages.log
      messages_13.02.28_13.37.37.0.log
      status.log

      $ ssh -l WorklightAdmin remoteWLhost 'tail /cygdrive/c/path/to/Worklight/logs/messages.log'
      [2/28/13 13:38:16:747 EST] jdbc.internal.DataSourceService A J2CA8001I
      [2/28/13 13:38:16:747 EST] jdbc.internal.DataSourceService A J2CA8001I
      [2/28/13 13:38:16:762 EST] jdbc.internal.DataSourceService A J2CA8001I
      [2/28/13 13:38:16:762 EST] jdbc.internal.JDBCDriverService A J2CA8001I
      [2/28/13 13:38:16:778 EST] tcpchannel.internal.TCPChannel I CWWKO0220I

      $ ssh WorklightAdmin@remoteWLhost
      Last login: Fri Mar 15 17:40:10 2013 from pavftrptwrb.sonebiz.com
      WorklightAdmin@remoteWLhost ~
      $

      scp WorklightAdmin@remoteWLhost:/cygdrive/c/path/to/Worklight/logs/messages.log messages.log.txt

Non-admin userID

If you try to connect to the Windows workstation using a non-administrator user ID, you might get error...

    XCIM0010E: An error occurred while connecting to the remote target ip_address.
    Cause: CTGRI0011E An error occurred when accessing the remote registry or service control manager.
...add the user account to the Administrators group...

  1. Go to...
      My Computer (right-click) | Manage | Local Users and Groups Users | user account | Member Of
  2. Add the Administrators group to the list of groups that this account belongs to.
  3. From the admin console, click...

Change public location in sshd_Config


# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile /home/.ssh/authorized_keys

Database cannot attached because it is already existed in MVC 5

PM> sqllocaldb.exe stop v11.0
LocalDB instance "v11.0" stopped.

PM> sqllocaldb.exe delete v11.0
LocalDB instance "v11.0" deleted.

Parse JSON in C#

  1. Post your JSON in http://json2csharp.com/. Take the resulting classes and merge duplicates, and you get:
    public class AddressComponent
    {
        public string long_name { get; set; }
        public string short_name { get; set; }
        public List<string> types { get; set; }
    }
    
    public class Bounds
    {
        public Location northeast { get; set; }
        public Location southwest { get; set; }
    }
    
    public class Location
    {
        public double lat { get; set; }
        public double lng { get; set; }
    }
    
    public class Geometry
    {
        public Bounds bounds { get; set; }
        public Location location { get; set; }
        public string location_type { get; set; }
        public Bounds viewport { get; set; }
    }
    
    public class Result
    {
        public List<AddressComponent> address_components { get; set; }
        public string formatted_address { get; set; }
        public Geometry geometry { get; set; }
        public bool partial_match { get; set; }
        public List<string> types { get; set; }
    }
    
    public class RootObject
    {
        public List<Result> results { get; set; }
        public string status { get; set; }
    }
  2. Deserialize your JSON with Json.NET like so:
        var root = JsonConvert.DeserializeObject<RootObject>(result);
  3. There are multiple results returned for your query, so you need to loop through the locations returned like so:
        foreach (var singleResult in root.results)
        {
            var location = singleResult.geometry.location;
            var latitude = location.lat;
            var longitude = location.lng;
            // Do whatever you want with them.
        }

Qt Type Convertor

// int to QString
QString::number(int)

// 

Qt Timer

Other way is using of built-in method start timer & event TimerEvent. Header:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
    int timerId;

protected:
    void timerEvent(QTimerEvent *event);
};

#endif // MAINWINDOW_H
Source:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    timerId = startTimer(1000);
}

MainWindow::~MainWindow()
{
    killTimer(timerId);
    delete ui;
}

void MainWindow::timerEvent(QTimerEvent *event)
{
    //qDebug() << "Update...";
    ui->label->setText(QString::number(m_count++)); 
}

Telnet server in IMX6 Linux OS

* mkdir /dev/pts
* mount -t  devpts devpts /dev/pts
*telnetd -l /bin/login

TFTP Server in Ubuntu

  1. Install following packages.
    sudo apt-get install xinetd tftpd tftp
    
  2. Create /etc/xinetd.d/tftp and put this entry
    service tftp
    {
    protocol        = udp
    port            = 69
    socket_type     = dgram
    wait            = yes
    user            = nobody
    server          = /usr/sbin/in.tftpd
    server_args     = /tftpboot
    disable         = no
    }
    
  3. Create a folder /tftpboot this should match whatever you gave in server_args. mostly it will be tftpboot
    sudo mkdir /tftpboot
    sudo chmod -R 777 /tftpboot
    sudo chown -R nobody /tftpboot
    
  4. Restart the xinetd service.
    sudo /etc/init.d/xinetd restart
    
    Now our tftp server is up and running.

    ## TFTP from Target
    GET: tftp -l [local file name] -r [remote file name] -g [server Ip]
    PUT: tftp -l [local file name] -r [remote file name] -p [server Ip]

Linux Commands

// Share Windows and VMWare
.. Enable and Create Share folder in VM -> Settings -> Share Folder >.......
.. linux command :  mkdir /mnt ...if mnt doesn't exit
                             sudo mount -t vmhgfs .host /mnt

Set up Qt 5.2 Environment

 Install curl program if system don't support
# apt-get install curl

To get repo script
#curl http://commondatastorage.googleapis.com/git-repo-downloads/repo
> repo

Change permission of repo
#chmod a+x repo

Create BSP folder and go in
#mkdir fsl-community-bsp
#cd  fsl-community-bsp

Download BSP
#../repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b dora
#../repo sync

Install SDK

Prepare the environment:
$MACHINE=imx6qsabresd . ./setup-environment build

Compile the SDK:
$sudo apt-get install texinfo
$sudo apt-get install gawk
$sudo apt-get install chrpath
$bitbake fsl-image-test -c populate_sdk   //Take long time to install



//Fail