0
blz? Next, I have a problem with the exception "Object reference not defined for an instance of an object", I have already sought several solutions, however, none satisfies and/or corrects my problem. In case anyone can help me...
string usuario;
protected void Page_Load(object sender, EventArgs e) {
//Área referente a consulta na base de dados em relação as metas da operadora
SqlConnection conexao = new SqlConnection(@ "Data Source=.\SQLEXPRESS;Initial Catalog=DB_COOPERATIVE;Integrated Security=True;"); //Definição da string de conexão
conexao.Open(); //É aberto a conexão com a base de dados
//Recuperar o código da pessoa através de seu nome
SqlCommand comandos2 = new SqlCommand("SELECT CODIGO_FUNCIONARIO from USUARIO where LOGIN_USUARIO='" + usuario + "'");
comandos2.Connection = conexao;
int cod_funcionario = Convert.ToInt16(comandos2.ExecuteScalar());
//Por fim, pelo código do funcionário obtido, é iniciado a busca por suas metas
SqlCommand comandos4 = new SqlCommand("SELECT VALOR_META from METAS where CODIGO_FUNCIONARIO='" + cod_funcionario + "'");
comandos4.Connection = conexao;
int metaArrecadacao = Convert.ToInt16(comandos4.ExecuteScalar());
double valorSemanal = metaArrecadacao / 5;
double valorDiario = metaArrecadacao / 30;
//Por fim é exibido ao operador as suas respectivas metas
//lblmensal.Text = Convert.ToString(metaArrecadacao);
//lblsemanal.Text = Convert.ToString(valorSemanal);
//lbldiaria.Text = Convert.ToString(valorDiario);
//Eventos ao momento em que o form é carregado
}
protected void Page_InitComplete(object sender, EventArgs e) {
string usuario = String.Format(Session["usuario"].ToString());
lblNome.Text = usuario;(AQUI OCORRE O ERRO)
}
The error happens in the line I referenced. When I run initially, the error does not occur, but when I change page in my project, the error happens.
I would need to see other parts of the code, but clearly there is no field
lblNome
. Unless the error is somewhere else. There are other problems in the code.– Maniero
Opa, speaks Maniero blz? Next, this error appears in all areas related to manipulation with the page Abels
– Pedro Cassone
Abels are with the attribute
runat="server"
?– William John Adam Trindade
Hello, this error occurs when I leave the homepage and go to another page within the application. If I am on the home page, this error is not triggered
– Pedro Cassone