Search code examples
c#odbcsqlanywhere

ODBC Driver ignores port parameters for SQL Anywhere 10


I'm trying to connect to a SQL Anywhere 10 database using an ODBC connection in C#. This connects fine with all the default parameters, but whenever I try to specify a port or IP address, it looks like it's completely ignored

My connection string is:

Driver={SQL Anywhere 10};uid=username;pwd=password;

Which works when connecting to the first database listed. I want to connect to the second database running on the computer, which is on a different port. I have tried:

Driver={SQL Anywhere 10};uid=username;pwd=password;port=1234;

Driver={SQL Anywhere 10};uid=username;pwd=password;LINKs=tcpip(host=192.168.1.1:1234)

Driver={SQL Anywhere 10};uid=username;pwd=password;DataSource=localhost:1234;

None of these have changed the connection at all, or even failed to connect

What is the correct string to use to specify port?

Or what other method can I use other than a System.Data.ODBC.ODBCConnection to connect where I can specify a port?


Solution

  • It looks like you're just making up connection attributes to try in the string...

    Try looking at documentation for the driver you're using --

    Driver={SQL Anywhere 10};UID=<user name>;DatabaseName=<database name>;EngineName=<database engine name>;AutoStop=YES;Integrated=NO;EncryptedPassword=3ff6c3114e;Debug=NO;DisableMultiRowFetch=NO;CommLinks='TCPIP{HOST=<database server name>;PORT=<port number for remote connections>}';Compress=NO

    Most of those attributes are optional, so here's a reduced string that may work for you --

    Driver={SQL Anywhere 10};UID=username;PWD=password;CommLinks='TCPIP{HOST=localhost;PORT=1234}'