I have a code, as shown below, where I am trying to insert data into a table and return the identifier (set by auto-increment) of the new element.
int newEquipmentID = new int(); query = database.ParameterizedQueryString("INSERT INTO Equipment (EquipmentTypeID) VALUES ({0})", "equipmenttypeID"); newEquipmentID = (int)database.Connection.ExecuteScalar(query, DefaultTimeout, equipment.EquipmentTypeID);
But it fails and returns null, as if a new element had not yet been added. But actually I see a new element that makes simple advice in the database.
My question is โwhenโ data is actually added to the database and how can I get the identifier of the newly added item. Thanks!
source share