I have a big problem: I want to to connect to a MS SQL Server but whatever I am doing it doesn't work... I don't know where my mistake lies..
const parse = require("csv-parse/lib/sync");
const fs = require("fs");
const path = require("path");
var mssql = require('mssql/msnodesqlv8');
var iconv = require('iconv-lite');
var http = require('http');
// Connection to SSMS Database
var dbConfig = {
host: 'localhost',
user: 'user',
server: 'server',
database: 'database',
options: {
trustedConnection: true,
useUTC: true
}
};
var connection = new mssql.Connection(dbConfig, function(err) {
var request = new mssql.Request(connection);
...
request.query(`INSERT INTO ${richtigername} (${namen}) VALUES (${values})`, function (err, recordset) {
if (err) {
console.log(err);
res.send(recordset)
}
mssql.close();
});
Now there is the error message:
TypeError: request is not a function
It is so difficult to get data into a SQL Server database.. the tool works fine with MySQL but SQL Server is horrible..
I have two more queries before this with also: request.query(...) and if (err) { console.log(err); res.send(recordset) ... MySQL is on the other hand so easy... only
connection.query(...) and before this
// Verbindung zur MySQL Datenbank
const connection = mysql.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'database'
});
and
// Verbindung zur Datenbank starten
connection.connect((error) => {
if (error) {
console.error(error);
} else {
}
})
}