Accessing the Microsoft SQL server in Node.js

Node.js provides different database drivers that can be added as node packages. There are packages for the MongoDB driver, the Microsoft SQL Server driver, and more. We will use the MS SQL driver for Node.js to connect with Microsoft SQL server databases. To install mssql you can run the npm install mssql –save command, or add it from the NPM package manager window, as shown in the following screenshot:

Accessing the Microsoft SQL server in Node.js

Tip

With the MSSQL driver, TCP/IP should be enabled for a corresponding SQL server instance.

Reading a record from the Microsoft SQL server database

In the DataService.js file, we will add the getProducts() ...

Get JavaScript for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.