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 :: how to make proptypes either or 
Javascript :: chrome input disable autofill 
Javascript :: get first element by class name jquery 
Javascript :: Both npm and yarn have created lockfiles for this application, 
Javascript :: get html input value by class name 
Javascript :: javascript take first element of array 
Javascript :: nuxt looks for npm_modules on express 
Javascript :: btoa javascript 
Javascript :: get first object key javascript 
Javascript :: delta time js 
Javascript :: nested loops js 
Javascript :: how to get selected value of dynamically created dropdown in jquery 
Javascript :: how to catch and throw error js 
Javascript :: insert variable in string javascript 
Javascript :: javascript remove object property 
Javascript :: Find smallest Number from array in javascript 
Javascript :: hide and show on button click in react js functional component 
Javascript :: make a get request in node js 
Javascript :: next js Pages with Dynamic Routes 
Javascript :: js two array combining with id 
Javascript :: column.footer jquery 
Javascript :: link button material ui 
Javascript :: jquery thousand separator 
Javascript :: js get type of variable 
Javascript :: js loop through array backwards with foreach 
Javascript :: how to hash with crypto Node.js 
Javascript :: react native text capitalize 
Javascript :: how to get seconds in timstamps js 
Javascript :: react navigation header background color 
Javascript :: js document.addEventListner 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =