3

I have been trying to use node-sqlanywhere to query my Sybase database.

However, I cannot seem to be able to connect to the database.

var sqlanywhere = require('sqlanywhere');
var sqlanywhere_conn = sqlanywhere.createConnection();

var sqlanywhere_conn_params = {
    DatabaseFile: 'C:\Users\support\Dropbox\database.db',
    AutoStart: 'YES',
    UserId: 'user_id',
    Password: 'password'
};

sqlanywhere_conn.connect(sqlanywhere_conn_params, function(){
    sqlanywhere_conn.prepare('SELECT * FROM some_table WHERE some_column = ?', function (err, stmt){
        if (err) throw err;
      // do something with the statement
    });
});

Whether I am trying to connect to the database using Server attribute or the DatabaseFile attribute, I always get error code -2005 No Connection Available.

That being said, I am able to connect to my database using Interactive SQL by either specifying the server or the database file.

So.. I must be missing something here and I can't figure it out !

Thanks !!

Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121
Antoine Cloutier
  • 1,330
  • 11
  • 23

1 Answers1

0

Try doubling up the backslash characters, like DatabaseFile: 'C:\\Users\\support\\Dropbox\\database.db'.

FYI you can also ask SQL Anywhere-specific questions on http://sqlanywhere-forum.sap.com.

Full disclosure: I work for SAP in SQL Anywhere engineering. I am responsible for both the node.js driver and the sqlanywhere-forum.sap.com site.

Graeme Perrow
  • 56,086
  • 21
  • 82
  • 121
  • Still not working :(. What should I be doing next ? I still get "No connection available", but like I mentionned, I am able through Interactive SQL to connect to my database and perform queries. I am kind of stuck on my project until I can make this work. Any and all help is appreciated :) – Antoine Cloutier Apr 07 '14 at 23:26
  • I feel dumb for not thinking about this earlier, but I need to realize this project with a Sybase version 9 database. I just installed SQL Anywhere 16 and it works perfectly (I did have to double the backslashes!). So, I am guessing that you have no intention on supporting version 9 ? (which would probably make sense). The database will **eventually** be upgraded to version 16, but that is unfortunately out of my control. – Antoine Cloutier Apr 08 '14 at 01:09
  • 1
    I'm afraid not. Version 9 has been end-of-life'd for several years now, and the client library that the node.js driver uses didn't exist back then. – Graeme Perrow Apr 08 '14 at 13:22
  • Any idea why I can successfully use your module to query my database on computer A and the same setup isn't working on computer B. The only difference is that computer B used to have SQL Anywhere 9 installed (now SQL Anywhere 16). I just created a new database with SA16 and am able just fine to connect to it using Interactive SQL but I can't get anything done in node, I always get "No connection available". The problem isn't with my syntax as it's working on computer A. Basically just wondering if you have any idea so I can investigate further. Thanks!! – Antoine Cloutier Apr 17 '14 at 15:47
  • I'm afraid I don't have enough information to help you. You're more likely to get a better answer if you post a new question on sqlanywhere-forum.sap.com with the full details. – Graeme Perrow Apr 17 '14 at 17:02