Eine gespeicherte Prozedur mit NodeJS- und MSSQL-Paketfehler ausführen
Im Versuch, das MSSQL NodeJS-Paket zu veranlassen, die Ergebnisse einer gespeicherten Prozedur von Microsoft SQL Server mit dem folgenden Code zurückzugeben. Allerdings ist der Fehler, den ich bekomme ...
[TypeError: Cannot read property 'type' of undefined]
Ich bin mir nicht sicher, ob ich die Eingaben richtig gemacht habe, da ich online nirgendwo ein Beispiel mit mehr als einer Eingabe finden konnte.
Irgendwelche Ideen
exports.executeSqlStoredProd = function (callback) {
var conn = new sqlDb.Connection(settings.dbConfig)
conn.connect().then(function () {
var req = new sqlDb.Request(conn);
req.input('ProductEntryID', req.Int, 3299);
req.input('LoginEntryID', req.Int, 4);
req.input('TempLoginEntryId', req.Int, -1);
req.input('AddToWishList', req.Bit, 0);
req.input('WebPortalId', req.Int, 0);
req.execute('J_ViewAProduct').then(function(err, recordsets) {
console.log(recordsets);
callback(recordsets)
})}).catch(function(err){
console.log(err);
callback(null, err);
});
}
Ich habe die Anfrage mit dem Paket "Seriate" erfolgreich ausgeführt, möchte aber lieber mssql verwenden. Der Code, der für "Seriate" funktioniert hat, ist unten.
exports.getVAP = function(req, resp, pid) {
sql.execute({
procedure: "J_ViewAProduct",
params: {
ProductEntryID: {
type: sql.INT,
val: pid
},
LoginEntryID: {
type: sql.Int,
val: 4
},
TempLoginEntryId: {
type: sql.Int,
val: -1
},
AddToWishList: {
type: sql.Bit,
val: 0
},
WebPortalId: {
type: sql.Int,
val: 0
}
}
}).then(function(results){
console.log(results)
httpMsgs.sendJSON(req, resp, results)
//httpMsgs.sendJSON(req, resp, results[0])
resp.end();
}), function(err){
httpMsgs.show500(req, resp, err)
}
};