Share a LocalDB instance with other users on the computer

MS LocalDB has the possibility to share your personal LocalDB instance with other users on the computer.

You can use the CLI tool SqlLocalDb.exe to share the instance. It is available in the Developer Command Prompt of Visual Studio.

This is the documentation of the share action:

share|h ["owner SID or account"] "private name" "shared name"
    Shares the specified private instance using the specified shared name.
    If the user SID or account name is omitted, it defaults to current user.


C:\Windows\System32>sqllocaldb share contosolab\doering MSSQLLocalDB ShareLocalDb
Private LocalDB instance "MSSQLLocalDB" (owner: CONTOSOLAB\doering) shared with the shared name: "ShareLocalDb".

Important: the argument “owner SID or account” must be your own user not the user you want to share the instance with.

The instance then appears as .\ShareLocalDb in the list.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>sqllocaldb info

You can use the shared instance in connection strings like this:

Data Source=(LocalDb)\.\ShareLocalDb;database=MyDatabase;trusted_connection=yes;


TFS/VSTS agent behind a corporate proxy

Many companies use a http proxy with authentication. Since TFS 2017 the agents are based on .NET Core to be cross-platform. The new agents are unable to obtain the proxy settings from the operating system (Internet Explorer settings).

I’ve found this solution to set a http proxy for the VSTS agents.

  1. Create a file .proxy in the agents root folder and write the proxy in it.


  2. Username and password can be set with environment variables
    [Environment]::SetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME", "proxyuser", "User")
    [Environment]::SetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD", "proxypassword", "User")

    See also the documentation on GitHub.

Sending all e-mails in development environment to a local folder

In the app.config/web.config you can use the configuration section <> <mailSettings> <smtp> to configure how to deliver e-mails which are sent using the MailMessage and SmtpClient classes in your program.

In development environment you usually don’t want the e-mails to be delivered. Today I’ve found a awesome configuration option, which enables that all outgoing e-mails go to an local folder or file share as eml files.

app.config / web.config
Sending an e-mail with .NET
Local pickup folder

How to get the Correlation ID of the current request in SharePoint

SharePoint generates for each request a random GUID which correlates all log messages in the ULS log which are printed during the current request. The Correlation ID is also printed to error pages. If you want more information about an error page you can use the Correlation ID to find the right log messages in the ULS log.

Recently I wanted to get the current request’s Correlation ID to share it with an external webservice to have the same correlation ID in all depending systems.

You can add following code to your ASP page to get the Correlation ID.


Alternative for Invoke-SqlCmd

Invoke-SqlCmd ist a great cmdlet for PowerShell for querying SQL databases. But sometimes you don’t want to install the extra requirement SQL Server Management Objects on the server.

Invoke-SqlCmd -ServerInstance $Server -Database $Database -Query "SELECT * FROM Staff"

There’s an simple alternative. Use the .NET classes in the System.Data.SqlClient namespace which are available on every computer which has the .NET framework installed.

function SqlQuery($server, $database, $query)
 $connection = New-Object System.Data.SqlClient.SqlConnection
 $connection.ConnectionString = "Server=$server;Database=$database;Integrated Security=True;"
 $command = $connection.CreateCommand()
 $command.CommandText = $query
 $result = $command.ExecuteReader()
 $table = new-object “System.Data.DataTable”
 return $table

SqlQuery $Server $Database "SELECT * FROM Staff"