Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node mssql

Installation
npm install mssql

Short Example: Use Connect String
const sql = require('mssql')

async () => {
    try {
        // make sure that any items are correctly URL encoded in the connection string
        await sql.connect('Server=localhost,1433;Database=database;User Id=username;Password=password;Encrypt=true')
        const result = await sql.query`select * from mytable where id = ${value}`
        console.dir(result)
    } catch (err) {
        // ... error checks
    }
}
Comment

mssql node js documentation

const sql = require('mssql')
const sqlConfig = {
  user: process.env.DB_USER,
  password: process.env.DB_PWD,
  database: process.env.DB_NAME,
  server: 'localhost',
  pool: {
    max: 10,
    min: 0,
    idleTimeoutMillis: 30000
  },
  options: {
    encrypt: true, // for azure
    trustServerCertificate: false // change to true for local dev / self-signed certs
  }
}

async () => {
 try {
  // make sure that any items are correctly URL encoded in the connection string
  await sql.connect(sqlConfig)
  const result = await sql.query`select * from mytable where id = ${value}`
  console.dir(result)
 } catch (err) {
  // ... error checks
 }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove comma from string jquery 
Javascript :: javascript count no of lines 
Javascript :: accessing object properties with bracket notation 
Javascript :: js count element tags 
Javascript :: javaScript setSeconds() Method 
Javascript :: how to use uniqid 
Javascript :: setting timeout in javascript 
Javascript :: merge array of objects javascript 
Javascript :: fill array with values javascript 
Javascript :: alpinejs with select 
Javascript :: @babel/plugin-proposal-optional-chaining 
Javascript :: next js image 
Javascript :: react uselazyquery and usequery 
Javascript :: get the text of a tag 
Javascript :: angular get element by classname 
Javascript :: run function then empty it 
Javascript :: date masking javascript to not allow / 
Javascript :: jquerry in bootstrap 
Javascript :: how to import dotenv in react 
Javascript :: select elements of an array starting by a certain letter javascript 
Javascript :: javascript set input value by id 
Javascript :: vscode 
Javascript :: react chart js 2 
Javascript :: remove .html from url express js 
Javascript :: how to add checked in javascript 
Javascript :: use style in react 
Javascript :: No provider for ReducerManager 
Javascript :: javascript regex Zero or one occurrence 
Javascript :: moment timezone set clock in another timezone 
Javascript :: replace jquery 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =