sqlanywhere / node-sqlanywhere

SAP SQL Anywhere Database Client for Node
Apache License 2.0
39 stars 37 forks source link

Sybase 16 not supported #7

Closed saquibkhan closed 8 years ago

saquibkhan commented 8 years ago

Sybase 16 not supported

gperrow-SAP commented 8 years ago

Can you be more specific about what problems you are seeing?

saquibkhan commented 8 years ago

I have a sybase 16 db file. When i am trying to connect to it I ma getting error to upgrade sybase server

Logs:

conn.connect({
     ^
Error: Code: -934 Msg: Unable to start specified database: Server must be upgraded to start database Database.db
    at Error (native)
    at Object.<anonymous> (C:\SAQUIB\git\Test\index.js:6:6)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
gperrow-SAP commented 8 years ago

That error message means that you are trying to run a database built with a newer version of SQL Anywhere than the server that is trying to start it. Do you have multiple versions of SQL Anywhere installed on your computer?

saquibkhan commented 8 years ago

Yes today I installed Sybase 16, and now I have both sybase 16 and sybase 11 But i was getting this error even when i was having only sybase 11 installed.

gperrow-SAP commented 8 years ago

You need to make sure that SQL Anywhere 16 is earlier in your path than SQL Anywhere 11 so that the node.js driver picks up the v16 version of dbcapi.dll. Then it will start the right version of the server. Alternatively, you could manually start the v16 server on the database and then run your node.js application, rather than having the application start the server.

saquibkhan commented 8 years ago

ok, if i keep the server open then connection is successful but i am getting below error on basic query:

    if (err) throw err;
                   ^
Error: Code: -2001 Msg: Invalid Object
    at Error (native)
    at C:\SAQUIB\git\Test\index.js:25:8

Test Code: (Note: I use any other table I get same error)

var conn_params = {
  Server  : 'DB_SERVER',
  UserId  : 'xxxxxxx',
  Password: 'xxxxxxxx'
};

conn.connect(conn_params, function() {
    console.log("Connection successful");

  conn.exec("SELECT * FROM sysobjects", function (err, rows) {
    if (err) throw err;
    console.log('Rows: ', rows);
    conn.disconnect();
  });
});
gperrow-SAP commented 8 years ago

I'm going to need the query, or preferably the whole index.js file. Feel free to remove passwords. If you'd rather not post it here, you can email it to me at graeme [dot] perrow [at] sap [dot] com.

saquibkhan commented 8 years ago

Please find the file below:

var sqlanywhere = require('sqlanywhere');

var conn = sqlanywhere.createConnection();

var conn_params = {
  Server  : 'DB_SERVER',
  UserId  : 'xxx',
  Password: 'xxx'
};

conn.connect(conn_params, function() {
  console.log("Connection successful");

  conn.exec("SELECT * FROM sysobjects", function (err, rows) {
    if (err) throw err;
    console.log('Rows: ', rows);
    conn.disconnect();
  });
});
gperrow-SAP commented 8 years ago

I removed my previous comment since I missed the error in your script. The callback function you supply for the connect call should take an error parameter, but it doesn't. If you change the connect call to this:

conn.connect(conn_params, function( err ) {
    if( err ) throw err;
    console.log("Connection successful");
    ...

You should see a connection error. Your connection parameters are probably incorrect, and the error message might give you enough information to fix it. If not, post the command you're using to start the database server.

saquibkhan commented 8 years ago

Yes I am getting following error on connection:

        if (err) throw err;
                       ^
Error: Code: -95 Msg: Parse error: Invalid or missing keyword near 'Server'
    at Error (native)
gperrow-SAP commented 8 years ago

Is SQL Anywhere 16 earlier in your path than SQL Anywhere 11? The Server connection parameter was added in SQL Anywhere 12, so the v16 driver should recognize it while the v11 driver would not.

saquibkhan commented 8 years ago

Thanks it worked.

Ujs85 commented 8 years ago

Hello I am facing semiler issue on my live server. I was publish my Asp.net MVC 4.0 project on server and installed Sql Anywhere 16 developer version. and create ODBC 64 database objects. and it was running smooth. but before 2-3 days i was installed Sql Anywhere 12 licence copy on server for another use. Now my site is not connecting database. It says "System.Data.EntityException: The underlying provider failed on Open. ---> iAnywhere.Data.SQLAnywhere.SAException: Unable to start database server at iAnywhere.Data.SQLAnywhere.SAConnection.Open()"

Error. Please help to solve this error. I am beginner of SQL Anywhere.

Thanks.

gperrow-SAP commented 8 years ago

Did you try the same solution? Is SQL Anywhere 12 earlier in your path than SQL Anywhere 16?

Ujs85 commented 8 years ago

Actually i read above all comment but i didnt get that where i can set or configure that my Sql Anywhere 16 run first. I am calling multiple database in single solution. So all database will call dynamic through application. Please give me steps or detail guideline.

gperrow-SAP commented 8 years ago

Like I said, set your path so that the SQL Anywhere 16 software is earlier than the SQL Anywhere 12 software. Or you can remove the SQL Anywhere 12 directories from your path entirely since it's unlikely you'll need both.

Ujs85 commented 8 years ago

Thanks for the reply but i still didnt understand that where i can find path? because my connection string is likely,

metadata=res:///DB.csdl|res:///DB.ssdl|res://*/DB.msl;provider=iAnywhere.Data.SQLAnywhere;provider //connection string="UserID=DBAq;Password=SQLq;DataSourceName=Testq"" providerName="System.Data.EntityClient"

and i setup ODBC using below steps,

Step 1) Open ODBC Data Source Administrator (64 bit) from All application.

Step 2) Click on to tab System DNS.

Step 3) Click Add button and select SQL Anywhere 16 and click finish.

Step 4) Now on ODBC Configuration for SQL Anywhere window, click to Login Window.

Step 5) Enter User ID of your database on User Id field. Step 6) Enter Password of your database. Step 7) On Action Tab select - "Start and connect to a database on this computer" option. Step 8) Browse database .db file from location. Step 9) Click Ok. button. Step 10) click on ODBC tab -> and enter Data Source Name for your reference and click on "Test Connection" button.

Step 11) if connection establish then click ok. Step 12) Repeat step 2 -11, to add another database.

gperrow-SAP commented 8 years ago

I'm talking about the Windows system path. The way to change it is slightly different depending on the version of Windows you are running. For Windows 8, find My Computer on your desktop or under the Start menu, right-click on it, and select Properties. Then click Advanced system settings, then Environment variables. Under "System variables", there should be an entry for PATH. You need to edit that value and make sure that your SQL Anywhere 16 bin64 directory is ahead of the SQL Anywhere 12 bin64 directory, or just remove SQL Anywhere 12 bin64.

Ujs85 commented 8 years ago

Thanks for quick reply. I really get frustrated due to this error. I remove SQL Anywhere 12 from System variables but still error is remain. Unable to start database server. If you have another solution please help.

gperrow-SAP commented 8 years ago

Sorry, I should have mentioned that if you change the system variables, you need to reboot the system for the changes to take effect. That's a Windows limitation.

Ujs85 commented 8 years ago

I have restart the server and new error is generate. "The underlying provider failed on Open. ---> iAnywhere.Data.SQLAnywhere.SAException: Unable to start specified database: Server must be upgraded to start database C:\PDMS Database\MainDB\MainDB.db at iAnywhere.Data.SQLAnywhere.SAConnection.Open()"

gperrow-SAP commented 8 years ago

It looks like it is trying to start the SQL Anywhere 12 server but the database was created or upgraded with SQL Anywhere 16. However given the connection string above, you're not using the node.js driver anyway. That looks like an ASP.NET thing, which I know nothing about.

You may want to post your question on http://sqlanywhere-forum.sap.com/ and someone can help you.