What I am trying to do is to capture in a textbox the identification number of a person, save the value in a variable, look for it in the database and show the name in label.
This is the code:
SqlConnection conexion = new SqlConnection("server=N ; database=CITISALUD ; integrated security = true");
conexion.Open();
string cc = TextBox1.Text;
string cadena = "select Nombre1, Nombre2, Apellido1, Apellido2 from Pacientes where Documento=" + (cc);
SqlCommand comando = new SqlCommand(cadena, conexion);
SqlDataReader registro = comando.ExecuteReader();
if (registro.Read())
{
Label1.Text = registro["Nombre1"].ToString();
Label2.Text = registro["Nombre2"].ToString();
Label3.Text = registro["Apellido1"].ToString();
Label4.Text = registro["Apellido2"].ToString();
}
else
Label5.Text = "No Existe";
conexion.Close();
But I get this error:
Se produjo la excepción System.Data.SqlClient.SqlException. HResult=0x80131904 Mensaje = The conversion of the nvarchar value ' 92012156148' overflowed an int column. Origen = .Net SqlClient Data Provider Seguimiento de la pila: <No se puede evaluar el seguimiento de la pila de excepciones>
The field in the table is nvarchar type.
Thanks for your help!
![](https://i.stack.imgur.com/Cbzwc.jpg)
Document = '+ cc' "
I run the application and it does not show me any error, but it also does not filter me through the document that is what I'm trying to do, it enters the if because I have a message that if it does not find the document, it says it does not exist.
I hope you can help me and thank you very much for what you have helped me.