Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jan 06, 2015 at 04:03 PM

    Hi Peter,

    You can remove the "DRIVER=Adaptive Server Anywhere 9.0;" portion of this connection string - you are not really accessing the ODBC driver manager through the ADO.NET driver. The SQL Anywhere ADO.NET driver uses another native DLL (dbdata9.dll) to do its communication directly to the server (which also references a language DLL: dblgen9.dll).

    ---

    Wen you go to deploy, it will be important that the deployed dbdata9.dll / dblgen9.dll bitness matches the .NET runtime bitness (x86 to x86, or x64 to x64). See KBA 1984310 for more information about this: https://service.sap.com/sap/support/notes/1984310

    Please let us know if you run into any other problems.

    Cheers,

    Jeff Albion

    SAP Active Global Support

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Jan 06, 2015 at 03:24 PM

    Hello Peter,

    I've asked a moderator to move this to the SQL Anywhere space, since you are in the Adaptive Server Enterprise (ASE) space.

    Regards

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 06, 2015 at 03:53 PM

    Hello Peter,

    I think we should add why we think this should be moved,
    Stefan did ask the moderator because you use AsaConnection we would expect
    AseConnection if you use the SAP ASE (Adaptive Server Enterprice) the Asaconnection
    is for SAP ASA (Adaptive Server Anywhere) this is two different Database
    Engines for different use cases.

    So if your database Engine is ASE you need to change the ADO.NET driver to the one for SAP ASE.

    Regards

    Niclas

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Niclas,

      Thanks, I placed the message in the wrong directory, but it is in fact the ASA connection. So now it is in the right place, thanks.

      Hope somebody can help.

      regards,

      Peter