Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem with ASA connection

Hello All,

I'm trying to connect to a sybase database trough C# code, but I cannot get it to work. I tested the connection first on a ODBC data resource from windows, everything works fine. But now i'm trying to access it directly from the code, and the connection string throws an error:

            string DeQuery = "query";

            string IDquery = String.Format("query");

            AsaConnection EchoConn = new AsaConnection();

            EchoConn.ConnectionString = 'Driver=Adaptive Server Anywhere 9.0;ENG=Hostname.Database-Name;UID=username;PWD=password;DBN=Database-Name;LINKS=TCPIP(HOST=hostname.domain)';

            EchoConn.Open();

            AsaCommand EchoComm = new AsaCommand(DeQuery, EchoConn);

            AsaDataReader EchoReader = EchoComm.ExecuteReader();

Executing the code I get an error: Invalid connection string. Error parsing connection parameter string Parameter name: value

Anyone has a solution for this issue?

Thanks!

With kind regards,

Peter Manuel

Former Member
replied

Hi Peter,

So I can reproduce the exception with your code as posted:

EchoConn.ConnectionString = "Driver=Adaptive Server Anywhere 9.0;ENG=Hostname.Database-Name;UID=username;PWD=password;DBN=Database-Name;LINKS=TCPIP(HOST=hostname.domain)";

And this Exception was returned, as expected:

System.ArgumentException was unhandled

  Message="Invalid connection string. Error parsing connection parameter string\r\nParameter name: value"

  Source="iAnywhere.Data.AsaClient"

  ParamName="value"

  StackTrace:

      at iAnywhere.Data.AsaClient.AsaConnection.ParseConnectionString(String connStr)

      at iAnywhere.Data.AsaClient.AsaConnection.set_ConnectionString(String value)

      at ...

If I remove exactly the text "DRIVER=Adaptive Server Anywhere 9.0;" from my connection string, I don't see the exception and the connection is attempted. (Although it still fails for myself with the exception "Database server not found" as the connection string I have typed isn't pointing to a valid server.)

Are you getting "Database server not found now", or another exception? If you start removing pieces of the connection string, what resulting string doesn't give you an exception?

Could you perhaps give a little example? First time working with sybase...

Your posted code seems to be okay, it just seems that you're having trouble constructing a valid connection string. Can you post the current exception you're seeing?

---

If this is your first time working with SQL Anywhere, may I ask why you're using SQL Anywhere version 9? This version has been end-of-life'd for quite some time now (meaning that it is out of engineering support for patches, but you can still receive help on this version from technical support).

Regards,

Jeff Albion

SAP Active Global Support

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question