Connectionstring property not initialized

Asked

Viewed 2,511 times

2

I’m trying to create a register of categories, the registration worked all right, but when I do the location of the records added to the register always returns the same error:

An unhandled Exception of type 'System.Invalidoperationexception' occurred in System.Data.dll

"Connectionstring property not initialized."

as shown in the image below:

Erro

I await answers

  • At first glance, the connected object that is received in the constructor is not filled with connectionString. You should look at the code snippet that defines which connectionstring to use from your app.config/web.config and see if the name in the configuration file matches what it is being used in the code.

  • 1

    Shows the constructor of this class and the Dalconexao class as well.

  • Post the method code Incluir, please. Probably in this method you should make an assignment to the property conexao.StringConxao and forgot to do it in the method Localizar

  • Enter the complete code of your class, not the print

1 answer

1

The connected object you are passing in the Sqldataadapter parameter has not been instantiated.

Try the following:

public DataTable Localizar(String Valor)
{
    DataTable tabela = new DataTable();
    conexao = new DALConexao();
    ....
}

or check the method of registration as you charged the connection object.

  • @Luiz Paulo Alvim Soares If the answer was useful to you, if you can mark it as accepted , so when other users view your question they will see that you already have a correct answer and accept it for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.