Comments (10)
// connection timeout, can set the attribute on ODBC driver connect :-
// note people have reported this attribute does not cover all cases, I have tested with no server // listening, and do receive error back within the timeout period. Can use conn_str directly as before.
var connectionObj = {
conn_str: connStr,
conn_timeout: 2
};
msnodesql.open(connectionObj, function (err, conn) {
if (err) {
console.error(err);
process.exit();
}
;
done(conn);
});
from node-sqlserver-v8.
Thanks, it's working, but as you said, it's not very reliable. Real timeout varies according to the type of test.
- I got 7s real timeout when connecting to unreachable host with timeout set to 1s.
- I got 14s real timeout when connecting to unreachable host with timeout set to 2s.
- I got 21s real timeout when connecting to reachable host not running SQL Server with timeout set to 1s.
from node-sqlserver-v8.
i added query timeout via the API, this seems to be more exact in terms of behavior.
I will take a look at adding query request cancel.
open(function (conn1) {
var queryObj = {
query_str : "waitfor delay \'00:00:15\';",
query_timeout : 20
};
conn1.query(queryObj, function(err, res) {
console.log(res);
console.log(err);
});
});
from node-sqlserver-v8.
Can you think of a simple example which should raise more than one error so I can take a look at this request.
from node-sqlserver-v8.
With the recent error handling changes, I think handling multiple errors would be a next logical step. With the following query, only the first error returns an error to the query callback:
RAISERROR('First Error', 1, 1);
RAISERROR('Second Error', 1, 1);
Interestingly, the callback does get called two times with a null error.
from node-sqlserver-v8.
OK, This should be supported on latest version.
from node-sqlserver-v8.
I have cancel on a branch checked in and appears to be working. It is a fairly substantial change so I will test over coming days before merging it across and releasing. You can now cancel a stored proc call, prepared query or vanilla query,
test('cancel single query from notifier using tmp connection - expect Operation canceled', function (test_done) {
var q = sql.query(conn_str, "waitfor delay \'00:00:20\';", function (err) {
assert(err);
assert(err.message.indexOf('Operation canceled') > 0);
test_done();
});
q.on('submitted', function () {
q.cancelQuery(function (err) {
assert(!err);
});
});
});
from node-sqlserver-v8.
closing let me know what else is required.
from node-sqlserver-v8.
@TimelordUK Can you please help me figure out how to handle multiple errors? This is my code:
sql.open(connectionString, function (err, con) {
if (err) {
console.log('failed to open ' + err.message)
}
const req = con.query('select a;select b;', (err) => {
console.log("done", err)
})
req.on("info", (msg) => {
console.log("info", msg)
})
req.on("error", (msg) => {
console.log("error", msg)
})
})
All I get is:
done { Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'a'. sqlstate: '42S22', code: 207 }
Running the comamnd via Tedious or SQL Server Management Studio gives me this:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'a'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'b'.
Thank you. Great job on adding all the missing features btw!
from node-sqlserver-v8.
ill release a fix for this
const sql = require('msnodesqlv8')
const connectionString = 'Driver={SQL Server Native Client 11.0}; Server=np:\\\\.\\pipe\\LOCALDB#E086FCD9\\tsql\\query; Database={master}; Trusted_Connection=Yes;'
sql.open(connectionString, function (err, con) {
if (err) {
console.log('failed to open ' + err.message)
}
const req = con.query('select a;select b;')
req.on("error", (msg) => {
console.log("error", msg)
})
})
error { [Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'a'.] sqlstate: '42S22', code: 207 }
error { [Error: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'b'.] sqlstate: '42S22', code: 207 }
from node-sqlserver-v8.
Related Issues (20)
- Change node-gyp path to download nodejs headers from msnodesqlv8 installation HOT 2
- Why are database field names garbled when using Chinese fields? HOT 3
- msnodesqlv8 can't find sqltypes.h HOT 2
- install msnodesqlv8 through npm failed HOT 2
- Keep saying Module not found of sqlserverv8 HOT 6
- Question: Using prepared query with Pool
- unable to build on CentOS7 HOT 3
- Prebuilt binaries for Node 20 / alpine HOT 3
- Cannot use without 'require'? HOT 1
- Module not found: Can't resolve '../build/Release/sqlserverv8' HOT 10
- Module did not self-register: sqlserverv8.node HOT 7
- npm install --save msnodesqlv8 fails MSBuild.exe failed with exit code: 1 HOT 5
- import { SqlClient } from "msnodesqlv8/types"; Cannot find module 'msnodesqlv8/types' or its corresponding type declarations HOT 1
- Unable to initialize msnodesql during Hot Module Reload (HMR) HOT 2
- Security vulnerability detected in latest HOT 1
- uncaughtException: Cannot read properties of null (reading 'query') HOT 3
- `ConcreteColumnType.parseSS` method tampers with plain date strings HOT 3
- Cannot find module '../build/Release/sqlserverv8.node' - Windows 10 / node.js v20.11.0/v21.6.1 HOT 1
- npm install results in LNK1127: library is corrupt HOT 1
- Uncaught Exception: static Sybase = new ServerDialect("Sybase")
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlserver-v8.