Hello everyone
I am starting programming in c sharp C#
I am trying to load the data of the controls
This is my Code
using (var Conexion = new SqlConnection(VariablesGlobales.CadenaConexion))
{
Conexion.Open();
string consultaSQL = "Select FechaFegistro, TipoFactura, TotalImporte, CodigoCliente from TblaFactura2 WHERE CodigoFactura =@CodigoFactura";
var comando = new SqlCommand(consultaSQL, Conexion);
comando.Parameters.AddWithValue("@CodigoFactura", txtCodigoFactura.Text);
// LD=LectorDatos
SqlDataReader LD = comando.ExecuteReader();
if (LD.Read() == true)
{
// Establecemos valores de la asignación, en el mismo orden de los valores de la consulta
DateTimePickerFechaRegistro.Value = LD.GetDateTime(LD.GetOrdinal("FechaFegistro"));
cboTipo_Factura.Text = LD.GetString(LD.GetOrdinal("TipoFactura"));
txtTotalImporte.Text = LD.GetDecimal(LD.GetOrdinal("TotalImporte")).ToString("N2");
txtCodigoCliente.Text = LD.GetInt64(LD.GetOrdinal("CodigoCliente"));
}
}
All the controls load me well,
but in this line of code an error appears and that control does not want to load.
txtCodigoCliente.Text = LD.GetInt64(LD.GetOrdinal("CodigoCliente"));
My database is: SQL Server and the field: Client Code, the data type is: bigint
The error that appears is:

The code is also put like this:
txtCodigoCliente.Text = LD.GetString(LD.GetOrdinal("CodigoCliente"));
And when I run it I get this error

I hope you can help me.