Can't able to connect TS file with SQL Server

Viewed 17

I'm working on a Project in which I have to insert data into SQL server when clicking on save button. I tried using msnodesqlv8 but with project it is giving an error. I wrote the DB connection code in TS file in which onclick of save button is written. like below:

const sql: SqlClient = require("msnodesqlv8");
                    
                    const connectionString = "Driver={SQL Server};Server="";Database="";Uid="";Pwd="";"
                    const query = "select * from myTable";

                    sql.query(connectionString,query,(err,rows) => {
                        console.log(rows);
                        console.log(err);
                    })
                    console.log();

I removed connection string details because it is working fine.

I tried to connect with DB making a seperate testing file like this: enter image description here

and it is fetcing the data from DB. But when I tried the same code in my project like: enter image description here then is is throwing an error like in screenshot. If anyone know, please answer this.

0 Answers
Related