Module: biz.dfch.PS.System.Data

This module provides Cmdlets that let you work with Microsoft SQL Server database (regular and LocalDB) by utilising System.Data.SqlClient (instead of relying on the buggy ‘SqlServerCmdletSnapin100’ snapin and its ‘Invoke-Sqlcmd’ implementation. You can set a ‘DefaultPrefix’ or an alias to call it the same as the Microsoft SQL Server supplied ‘Invoke-Sqlcmd’.

Furthermore you can work with LocalDB instances (as used by Visual Studio and others) by specifying a connection string such as:
‘Data Source=(LocalDB)\v11.0;AttachDbFilename=”C:\VS\prj1\bin\Data\ApplicationDatabase.mdf”;IntegratedSecurity=True;Connect Timeout=30’

Again this module is published under the Apache 2.0 license.

You can download the module on GitHub at https://github.com/dfch/biz.dfch.PS.System.Data or you can get it on NuGet with ‘Install-Package biz.dfch.PS.System.Data’ (https://www.nuget.org/packages/biz.dfch.PS.System.Data/)

CommandType Name                    ModuleName
----------- ----                    ----------
Function    Invoke-SystemDataSqlCmd biz.dfch.PS.System.Data

 

Note:

* This module updates and enhances the previous implementation of my ‘Invoke-SqlCmd‘.

* For a description on ConnectionStrings and SqlConnectionStringBuilder with LocaolDB see:

SqlClient Support for LocalDB
http://msdn.microsoft.com/en-us/library/hh309441%28v=vs.110%29.aspx

* For a description on PSBase which is needed to work with the ConnectionStringBuilder see:

What’s up with PSBASE, PSEXTENDED, PSADAPTED, and PSOBJECT?
http://blogs.msdn.com/b/powershell/archive/2006/11/24/what-s-up-with-psbase-psextended-psadapted-and-psobject.aspx

 

Trackbacks

  1. […] === UPDATE 2014-10-19 === I created a separate module that uses the SqlClient where you do not have to specify the command type === For the full module and description see my Post Module: biz.dfch.PS.System.Data. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: