I am using sybase 12 and .net, in the repository I have everything that is called to the database with select/ or the get method works bine but what are update/insert (that is, post and put) do not work and give the error
"A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied."*...
My question or what I don't understand is if for the SELECT works but for an INSERT it does not, so it is not a problem with the code or with .net... and the base is not turned off (the error says that a socket in the base is turned off and that is why it cannot do the insert) but it can doing a select should be able to do an update... does anyone know what it could be?
This is the example, and fail before the line
await conexion.ExecuteAsync(sqlInserts, parametrosInserts);
public async Task<bool> RenaperUpdateEstadoFallecidosBorrados(string dni, string fecha)
{
try
{
using (var conexion = _conexionSybase)
{
await conexion.OpenAsync();
using (var transaction = conexion.BeginTransaction())
{
try
{
var sqlSelect = @"SELECT * FROM beneficiarios_renaper WHERE dni = convert(INT, @dni)";
var parametrosSelect = new { @dni = dni };
var beneficiario = await conexion.QueryFirstOrDefaultAsync<DtoDeRenaper>(sqlSelect, parametrosSelect);
if (beneficiario != null)
{
beneficiario.estado = "B";
var sqlUpdate = @"UPDATE beneficiarios_renaper SET estado = @estado, fecha_estado = @fecha_estado WHERE dni = convert(int,@dni)";
var parametrosUpdate = new
{
@estado = beneficiario.estado,
@fecha_estado = DateTime.Now,
@dni = beneficiario.dni
};
// Actualizar el estado del beneficiario
await conexion.ExecuteAsync(sqlUpdate, parametrosUpdate);
var mensaje = "registro actualizado, estado B!";
var sqlInsert = @"INSERT INTO seguimiento
(dni, sexo, fecha_alta, estado_mensaje, mensaje)
VALUES (@dni, @sexo, @fecha_alta, @estado_mensaje, @mensaje)";
var parametrosInsert = new
{
@dni = beneficiario.dni,
@sexo = beneficiario.sexo,
@fecha_alta = DateTime.Now,
@estado_mensaje = 2,
@mensaje = mensaje
};
// Registrar el seguimiento
await conexion.ExecuteAsync(sqlInsert, parametrosInsert);
var mensajeDos = "fecha Grabada con exito para Aviso";
var sqlInserts = @"INSERT INTO seguimiento
(dni, sexo, fecha_alta, estado_mensaje, mensaje)
VALUES (@dni, @sexo, @fecha_alta, @estado_mensaje, @mensaje)";
var parametrosInserts = new
{
@dni = 99999999,
@sexo = beneficiario.sexo,
@fecha_alta = fecha,
@estado_mensaje = 4,
@mensaje = mensajeDos
};
// Registrar el seguimiento
await conexion.ExecuteAsync(sqlInserts, parametrosInserts);
transaction.Commit(); // Se confirman los cambios en la base de datos
return true;
}
return false;
}
catch (Exception ex)
{
transaction.Rollback(); // Se revierten los cambios en caso de error
Console.WriteLine("Error: " + ex.Message);
// Manejar la excepción según tus necesidades
return false;
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error de conexión: " + ex.Message);
// Manejar la excepción según tus necesidades
return false;
}
}
The only post I found with a similar error is this one --> Sybase ASE + .NetCore (+ Dapper) Exception: request to send or receive data was disallowed because the socket is not connected ... no address but it doesn't give much information and the issue of int64/int32 doesn't seem to be the problem since I use int and not long