1

I am using following c# code to query a Sybase database(driver - Adaptive Server Enterprise). -

    string query = “select * from view_Test”;
    DataTable dt = new DataTable();
    OdbcConnection con = new OdbcConnection();
    con.ConnectionString = connStr;
    OdbcCommand selectCommand = new OdbcCommand(query, con);
    OdbcDataAdapter dataAdatper = new OdbcDataAdapter(selectCommand);                   
    dataAdatper.Fill(dt);

dt is getting populated but at the same time this code is throwing following exception -

  System.Data.Odbc.OdbcException occurred
  HResult=-2146232009
  Message=""
  Source=""
  ErrorCode=-2146232009

if I select columns that do not have any null values or not Boolean, then the same code does not throw any exception.

But when I use DDTek.Sybase or Sybase.AdoNet4.AseClient dlls, the same code(class names are replaced by dll specific class names.eg, OdbcConnection is replaced by AseConnection) works.

Please help to resolve this issue

Anirban Paul
  • 1,065
  • 1
  • 16
  • 22
  • There could be an `InnerException` with more details. Try catching it in the debugger and drilling into Details or using `exception.ToString()` to display the full text for nested exceptions as per this answer [What is the proper way to display the full InnerException?](http://stackoverflow.com/questions/5928976/what-is-the-proper-way-to-display-the-full-innerexception) – Tone Apr 14 '16 at 11:21
  • InnerException is null – Anirban Paul Apr 14 '16 at 11:55
  • If the same code works with the specific vendor driver then I would suspect it's your connection string at fault (most likely it will be different for an ODBC connection). Maybe one of these links will help [link](http://stackoverflow.com/questions/2926817/which-to-use-oledb-or-odbc-for-sybase), [link](https://www.connectionstrings.com/adaptive-server-enterprise-odbc-driver/), [link](https://msdn.microsoft.com/en-us/library/hh302811(v=sql.110).aspx), or you might turn up something from a Google search for "sybase Adaptive Server Enterprise odbc .net". Sorry it's not a product I use. – Tone Apr 14 '16 at 19:51
  • For obvious reason, the connection string I am using for odbc is different from other drivers. Since other select,insert,update queries are working for the current connection string of odbc, I don't think connection string can be an issue. – Anirban Paul Apr 15 '16 at 01:40

0 Answers0