1. Has anyone successfully used ODBC from c# to Sybase ASE?
2. Or Better, has anyone successfully used Sybase ASE with .NET Core?
I am using .NET Core 1.1 and the current Sybase.AdoNet4.AseClient.dll doesn't work, so I am attempting to use ODBC. I have tried to use two ODBC packages:
- Mono.Data.OdbcCore (NuGet)
- MSA.Net.Core.ODBC (NuGet)
Both work well with in-line queries and both work well calling a Sybase Store Procedures WITHOUT Parameter but both have the same exact error when trying to send parameters to a sp, where the parameters are required.
Here is a snippet:
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "XX_GetLookUp";
command.Parameters.Add("@Type", OdbcType.VarChar).Value = "ACC";
using (var reader = command.ExecuteReader()) {
...
}
I constantly receiving the following error during the command.ExecuteReader(): System.Data.Odbc.OdbcException: 'ERROR [ZZZZZ] [SAP][ASE ODBC Driver][Adaptive Server Enterprise]Procedure iKYC_GetLookUp expects parameter @Type, which was not supplied.
I have tried to use Type with and without the @ but each generate the same error.
I did try several other flavors as well:
- command.CommandText = "{call dbo.iKYC_GetLookUp(?)}";
- command.CommandText = "{call dbo.iKYC_GetLookUp}";
- command.CommandText = "{dbo.iKYC_GetLookUp(?)}";
- command.CommandText = "dbo.iKYC_GetLookUp(?)";
- command.CommandText = "dbo.iKYC_GetLookUp ?";
Where each above generates: System.Runtime.InteropServices.SEHException: 'External component has thrown an exception.'
I also tried to build the parameter object separate, with no luck (same error, missing @Type):
OdbcParameter p = new OdbcParameter();
p.ParameterName = "@Type";
p.DbType = DbType.AnsiString;
p.Direction = ParameterDirection.InputOutput;
p.Value = "ACC";
cmd.Parameters.Add(p);
As stated prior, if I make the parameter as null, on the store procedure, the code works and data is returned as expected, so the issue appears to be around the parameters being passed.
Has anyone successfully used ODBC from c# to Sybase ASE? Has anyone successfully used Sybase ASE with .NET Core?
Additional information: I am using Visual Studio 2017 (v 15.2). Core 1.1 and using Sybase ASE 16.0 sp2.