|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OdbcCommand, MySql and auto-increment fieldHi
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 -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "Ben Fidge" <ben.fidge@nospambtopenworld.com> wrote in message news:O5XooLF6FHA.2676@TK2MSFTNGP15.phx.gbl... > 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 > > |
|||||||||||||||||||||||