var tds = require('tds');
var MSsqlSettng= {
userName: 'sa',
password: '1234',
server: '127.0.0.1',//localhost\\sqlexpress // You can use 'localhost\\instance' to connect to named instance
database: 'dbname',
pool: {
max: 10, //The maximum number of connections there can be in the pool (default: 10).
min: 0, //The minimun of connections there can be in the pool (default: 0).
idleTimeoutMillis: 30000//The Number of milliseconds before closing an unused connection (default: 30000).
},
timeout: 15000,//Connection timeout in ms (default: 15000).
port:1433
};
var conn = new tds.Connection(MSsqlSettng)
conn.connect(function (error) {
if (error != null) {
console.error('Received error', error);
} else {
console.log('Now connected, can start using');
var stmt = conn.createStatement('SELECT @Param1 AS Value1, @Param2 AS Value2', {
Param1: { type: 'VarChar', size: 7 },
Param2: { type: 'Int' }
});
stmt.on('row', function (row) {
console.log('Got values:', row.getValue('Value1'), row.getValue('Value2'));
});
stmt.execute({ Param1: 'myval', Param2: 15 });
}
});
conn.on('error', function (error) {
console.error('Received error', error);
});
conn.on('message', function (message) {
console.info('Received info', message);
});
conn.end();
while running above code got message in console.
Received error [TypeError: Cannot call method 'write' of null]
I am using below code:
while running above code got message in console.
Received error [TypeError: Cannot call method 'write' of null]
Please let me know whats the issue.