Often people ask me how to retrieve the value of an autoincrement column when they are using the MySqlCommandBuilder object. Generally this is done by appending something like ";SELECT last_insert_id()" onto the generated insert command text. Command builder objects usually provide some type of syntax where a user can indicate that they want this to be done. Connector/Net 1.0 had some syntax for this but starting with Connector/Net 5.0 that all changed.
With the new ADO.Net 2.0 API, Microsoft did not directly provide for any type of API that users could use for selecting this. With ADO.Net 2.0, there are two things that need to happen. First, a SELECT statement similar to above must be attached to the INSERT command. Second, the command object must have its UpdatedRowSource property set to Both or FirstReturnedRecord. What this does is tell the data adapter update engine to take the …
[Read more]