Hi,
I'm using the .NET-Connector with C#. I have a question about how to get an auto-incremented primaykey value after inserting data.
Therefore i've got a table like this:
CREATE TABLE `images` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE (`id`)
);
Now i'm inserting a row like this:
command = connection.CreateCommand();
command.CommandText = "INSERT INTO `images` (`id`, `name`) VALUES (NULL, 'test');";
MySqlDataReader result = command.ExecuteReader();
How can i get the newly generated id? (Also in case there are more datasets with name "test".)
regards cm
I'm using the .NET-Connector with C#. I have a question about how to get an auto-incremented primaykey value after inserting data.
Therefore i've got a table like this:
CREATE TABLE `images` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` TEXT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE (`id`)
);
Now i'm inserting a row like this:
command = connection.CreateCommand();
command.CommandText = "INSERT INTO `images` (`id`, `name`) VALUES (NULL, 'test');";
MySqlDataReader result = command.ExecuteReader();
How can i get the newly generated id? (Also in case there are more datasets with name "test".)
regards cm