Closed ModuleHunter closed 3 months ago
Can you try running your connection code independently without going through Vue to see what happens? The error message is from Vue and not Tedious
Yeah, oddly, it works when I run it outside of Vue.
My best guess is that you're trying to read from the database before the connection is fully established in your Vue application
Isn't vue a front end framework? Tedious only works on Node.js, not in the browser.
Reading from the database actually happens after connection.connect(); command, but I did not include that code above. Anyway, running Tedious in Vue was most likely the issue because it just works in a separate Node instance. This assessment also explains why I could not find other users online having the same problem. Admittedly, I'm fairly new to Node.
connection.connect()
initiates the connection asynchronously. You need to put the code that runs after the connection is established inside
connection.on('connect', function(err) {
// Insert calls here
});
I can confirm that my code already runs inside the connect event. Everything works as desired now.
Hi @ModuleHunter, thanks for confirming that it is working now. Will close this one for now.
Question No matter what settings I use, tedious outputs the above error message when I want to connect to a MS SQL Server. It does not matter whether it is a remote server or a local server. I checked all possible connection settings (TCP/IP) in Sql Server Configuration Manager and experimented with various values (and restarted the server), but no luck. SQL Logins are also enabled. I installed NodeJS (20.16.0.0) only a few days ago on a fresh Windows 10. I also tried the 'mssql' extension but it outputs the same error message, too. I even added NodeJS as exception to Windows' firewall. I tried 'msnodesqlv8' as driver and started MS SQL Server Browser service, but just nothing helps.
This is my current connection code:
Console output:
It should be noted that I can connect to the servers without problems in SQL Server Management Studio by using SQL Logins. I use Vue with Vite for a web application if that helps.
My package.json: