I have a Web Api using express and Tedious to store some data on Azure SQL database. With nvarchar
types and int
types it works well, but when I try to save DateTime
value I get an error message:
Insert into Proxy (Ip, RequisitionDate)
values ('1', '2016-05-18 3:32:21' )
Error:
RequestError: Validation failed for parameter 'RequisitionDate'. Invalid date.] message: 'Validation failed for parameter \'RequisitionDate\'. Invalid date.', code: 'EPARAM' }
Well, the interesting thing is that
Insert into Proxy (Ip, RequisitionDate)
values ('1', '2016-05-18 3:32:21')
is the query that i execute in node.js api:
var query = "Insert into Proxy (Ip,RequisitionDate) values ( '"+ ip + "', '"+ date + "' )";
console.log(query); // Insert into Proxy (Ip,RequisitionDate) values ( '1', '2016-05-18 3:32:21' )
request = new Request(query, function(err) {
if (err) {
console.log(err);}
});
request.addParameter('Ip', TYPES.NVarChar,'SQL Server Express 2014');
request.addParameter('RequisitionDate', TYPES.DateTime , 'SQLEXPRESS2014');
connection.execSql(request);
}
If I execute the query direct on the SqlManager Studio, it works ok.