Search code examples
mariadbsql-updateodbcvisual-studio-2019tableadapter

Can't generate Update query in TableAdapter using MariaDB ODBC connector


I have a MariaDB Database which contains 1 table with a primary key. The Database is named Recus, the table Recu and the primary key Numero.

In my C# project, I add a DataSet and connect to the database using ODBC with MariaDB connector. Here the connection string:

Dsn=GestionRecus;Driver={MariaDB ODBC 3.1 Driver};Server=127.0.0.1;User=*****;Password=*****;Database=Recus;

The connection works fine. The problem is, even though I have a single table with a primary key, with the checkbox "Create method to send updates directly to the database" that is always grayed out.

Here is my table creation script:

CREATE TABLE `Recu` (
  `Numero` INT(5) UNSIGNED ZEROFILL NOT NULL,
  `Annee` INT(4) DEFAULT NULL,
  `Nom` VARCHAR(120) DEFAULT NULL,
  `Rue` VARCHAR(120) DEFAULT NULL,
  `Ville` VARCHAR(120) DEFAULT NULL,
  `Province` VARCHAR(40) DEFAULT NULL,
  `Pays` VARCHAR(30) DEFAULT NULL,
  `CodePostal` VARCHAR(7) DEFAULT NULL,
  `Telephone` VARCHAR(30) DEFAULT NULL,
  `MontantA` DOUBLE DEFAULT NULL,
  `MontantB` DOUBLE DEFAULT NULL,
  `DateAjout` DATE DEFAULT NULL,
  `Courriel` VARCHAR(80) DEFAULT NULL,
  `Imprime` INT(1) DEFAULT NULL,
  `Envoye` INT(1) DEFAULT NULL,
  PRIMARY KEY (`Numero`)
) ENGINE=INNODB DEFAULT CHARSET=utf8;

Therefore, I can't figure how to have an Update method available to my TableAdapter.

I'm using Visual Studio 2019.

What am I missing to get this to work?


Solution

  • Finally, it seems to be a bug, either with VS 2019 or with ODBC connector... The same connector worked fine in VS 2013 though so it solved my problem.

    I simply created a blank project in VS 2013, created a new DataSource and moved files that were created to my VS2019 project and voilà!

    Can't believe I spent so much time trying to figure out what I was doing wrong.