0
I need to make an access to a database where I put the data myself, the insertion part is working, but now I need to "take" the data again when I click on the button, only it does not matter the way I always do give that error message:
System.Invalidoperationexception: 'Executereader: Connection property has not been initialized.'
My code is in that form:
public void RetornaUser(string Service)
{
cmd = new SqlCommand("SELECT * from Logins WHERE Servico = @Service AND Estado = @Estado");
cmd.Parameters.AddWithValue("@Servico", Service);
cmd.Parameters.AddWithValue("@Estado", Estado);
con.Open();
SqlDataReader leitor = cmd.ExecuteReader();
while (leitor.Read())
{
//passo os valores para o objeto cliente
//que será retornado
string Login = leitor["Login"].ToString();
MessageBox.Show(Login);
}
//fecha conexão
con.Close();
}
In case you want to see all the code this HERE
In case I wanted to know how I do to remove the data and move to a variable so that my function returns to the other the account data so that it can use.
do not forget to mark your answer as the correct one
– Richard Dias