[_] .net tableadapters and MySQL LAST_INSERT_ID command
Jason Nevin
jason_nevin at yahoo.co.uk
Mon May 19 18:12:01 BST 2008
I'm using tableadapters to insert a row into a MySQL database. I want to get the primary key of the inserted row returned. Normally I'd tag a SELECT SCOPE_IDENTITY() statement onto the end of my insert and make the command a scalar but when I use the equivalent MySQL command (SELECT LAST_INSERT_ID()) I get a syntax error. Does anybody have a working example? Here is my SQL statement; INSERT INTO tblaccess (siteid, floor, room, area, reason, accessed, accessdate, comment) VALUES (?, ?, ?, ?, ?, ?, ?, ?); SELECT LAST_INSERT_ID() AS ID; And I get error "Unable to parse query text" Thanks.