When I get this error in .Net Core web api DAL call, here are things I've found that were the cause.
It's a generic message meaning "something went wrong communicating"
1. Convert the input args from int64 to int32, because Sybase sucks at int64s.
2. If you forget to put the @ in front of the argument name in the struct.(Even though on SO they say the @s don't belong)(I tested a working call removing the @ and it worked fine, so this may be spurious)
3. Your timeout could be to short, try adding 'Connection Timeout = 600;' if you are using ASE (Sybase)
4. Try changing all int64s to int32s in the return object
5. Try hard coding the variable into the SQL to see if that works (then you know it's something to do with the parameters.
6. re write not using dapper to see if that gives you insight
using ( IDbConnection db = new AseConnection( aseSqlConnectionString ) )
{
db.Open( );
using ( IDbCommand command = db.CreateCommand( ) )
{
command.CommandText = sql;
var parameter = command.CreateParameter();
parameter.ParameterName = "@enrtypeid";
parameter.Value = EnrTypeId;
command.Parameters.Add(parameter); ;
using (var reader = command.ExecuteReader())
{
// Get the results.
while (reader.Read())
{
var col1= reader.GetString(0);
var col2= reader.GetString(1);
// Do something with the data...
}
}
db.Close( );
}
}
No comments:
Post a Comment