In the previous post we did an overview of the different Node.js drivers for Microsoft SQL Server. There was a comparison between different modules for SQL Server and were considered and their advantages and disadvantages
Developers who work mainly with Node.js and open source technologies have experience how to build and debug Node applications. People, dealing with Microsoft SQL Server usually have more experience with Visual Studio and Microsoft platforms. It is also possible to use SQL Server Data Tools with VS
Node.js Tools for Visual Studio:
Node.js Tools for Visual Studio is a good solution if you want to get advantages from both – Node.js and SQL Server ( it is not a requirement – it just make development suing both technologies easier ).
The first public Alpha is released in November, 2013. Beta 1.0 is available from April, 2014 and in July is relapsed Beta 2.0
Node.js Tools for Visual Studio, aka NTVS, is a free/OSS plug-in that turns Visual Studio into a Node.js IDE. It only takes a few steps to get setup so let’s jump right into it.
You need to have installed:
- Visual Studio 2012 or 2013 ( Express for WEB, Professional, Premium or Ultimate)
- Node.js Tools for Visual Studio
NTVS supports Editing, Intellisense, Profiling, npm, TypeScript, Debugging locally and remotely (Windows/ Mac OS /Linux), as well Azure Web Sites and Cloud Service.
It id designed, developed, and supported by Microsoft and the community.
The interactive window is part of NTVS
IntelliSense exposes results of analyzing your programs in three different forms: completions, signature help, and quick info.
Node.js Tools allows you to create projects using the Visual Studio project system. Project files (.njsproj) reference all the source and content files associated with your project, showing them all in the Solution Explorer window and enabling NTVS to most efficiently work with your files.
You can use templates to create Node.js projects – console applications, web applications, Node.js + Express apps and Microsoft Azure Node.js apps/
You can also use the integrated debugger in Visual Studio
Below you can find examples how to start with the most popular Node.js drivers for Microsoft SQL Server
The connection string – the example is given with Azure SQL database, but you can adapt it for SQL Server on premises.
Create query using Node.js and node-sqlserver-unofficial
Configuration – how to configure credentials for SQL Server Database with Node.JS + tedious
NTLM support just landed in Tedious driver :
Execute query using tedious.
Creating a connection to SQL Server using tedious.
Insert Query, using tedious Node.js driver.
Tedious-ntlm is a forked version of Tedious is a work in progress towards NTLM authentication.
Sample connection string is demonstrated below:
- Edge.js and edge-sql
Connection string / using environment variables
This is the default approach when you are using edge-sql
Query MS SQL Server directly using Edge.js
Query SQL Server directly using Edge.js / code to set the connections in Node.js
Handle query results ( edge-sql )
- Execute .NET code to query SQL Server
Edje.js ia a Node.js module, providing native binding to .Net world:
It is possible to create .NET library, implementing any queries, that you can create in .NET with ADO.Net and after that to import this library in your Node.js project and invoke methods using Edge.js module.
Create a .NET class library
Import the .Net assembly and use it’s API in Node.js + Edge application ( you should specify the method, that will be invoked )
Invoke a specified method from Node.js
The use of Node.js, Visual Studio and SQL Server makes it easy and flexible the creation of multiplatform data centric applications (on premises and in the cloud).
In the next part of this article you can learn how to use Node.js module for Microsoft SQL Server / Azure SQL Database in Microsoft Azure applications (Azure Web Sites and Azure Cloud Services ). We will take a look at the best practices and cover different use cases.
My original post is published on Infragistics community blog .
If you want more information about how to use Microsoft SQL Server & Node.js feel free to contact me at firstname.lastname@example.org