nodejs mssql insert with parameters

后端 未结 1 562
傲寒
傲寒 2020-12-20 15:24

I\'m new to NodeJS where I\'m trying to insert into a table with parameters so I can avoid SQL Injection and just escape any characters that might cause issues.

So

1条回答
  •  时光说笑
    2020-12-20 16:00

    You can use the connection pool request object to add parameters, e.g.

    const request = pool.request()
    request.input('myval', sql.VarChar, 'value')
    request.query('insert into testtable (somecolumn) values (@myval)', (err, result) => {
        console.dir(result)
    })
    

    0 讨论(0)
提交回复
热议问题