MYSQL DOTNET CONNECTION (NAV 2016)

clemboclembo Member Posts: 122
I need to read some record from MYSQL table.
In a codeunit I have this code:

MySqlConnection := MySqlConnection.MySqlConnection;
MySqlCommand := MySqlCommand.MySqlCommand;
MySqlConnection.ConnectionString('server=localhost;uid=root;pwd=lufra9702;DATABASE=sys');
MySqlConnection.Open;

MySqlCommand.Connection := MySqlConnection;
MySqlCommand.CommandText := 'SELECT * FROM Table';
MySqlCommand.ExecuteReader;

When I try to execute it shows an error (see attached image).


Cannot serialize an instance of the following .NET framework object: assembly MySqlData, Version=6.9.8.0, Culture =neutral, PublicKeyToken.....

Where is the problem?

error triggered when trying to execute this statement:


MySqlCommand.Connection := MySqlConnection;

Comments

  • DuikmeesterDuikmeester Member Posts: 308
    Are your DotNet variables declared Client or Server side?
  • EvREvR Member Posts: 178
    edited 2016-01-08
    Try using the default constructor? MySqlConnection(ConnectionString).
    By the way, now the whole internet knows your root password ;)
Sign In or Register to comment.