OdbcCommand, MySql and auto-increment field

  • Thread starter Thread starter Ben Fidge
  • Start date Start date
B

Ben Fidge

Hi

I have a scenario where i'm writing to a MySql table using OdbcCommand and
the table has an auto-increment field that needs returning after the
"insert" statement executes.

How do I do this?

I've tried creating am Output parameter but that doesn't get populated after
the call to OdbcCommand.ExecuteNonQuery(). This may be because in my
"insert" statemement I'm using "?" to denote parameters as opposed to using
proper named parameters. I also can't seem to get these to work corretly
either.

Any help gratefully received,

Ben
 
Is it a relatively new version of MySQL? If yes, then you can use SELECT
@@IDENTITY to get the latest id field's value.

HTH
ALTAF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top