[Access database] how to get the last row inserted?
-
i want to insert a new row inside my microsoft access database, i do it, but i need it immediately. how?
Although this is a question to database forum (if there is), I know a little about it so I'll help... I personally work with database that doesn't stop to work (there are always a few people that can use the database), you should always take that risk! because if some-one inserts a row while you insert a row, you can both edit the same row in the end. I'll show you the command line for the last inserted row, and then I'm going to show you the better way. So this is command to get the last row: Select Top 1 * From tblTable Order By DESC (ofcourse no case-sensetive in here) tblTable = the table ID-Field = the ID or some other field that increases by time (eg. Date\Time) Now this is not good because if two people add a row, at the same time, they will, in the end see the same row, the last row inserted, and not their own. The better way which I prefer is to save the variables from the insert command, and just do a "Where" statement in the select command. eg: Select * from tblTable Where = '{0}' And = '{1}' etc. etc... Hope I helped... NaNg
-
i want to insert a new row inside my microsoft access database, i do it, but i need it immediately. how?
Hi! Don't know if I understand what you want, but if you need the value of an AutoValue that Access has assigned to a field in your newly-inserted row, you can look for "@@Identity". Another way could be to create your IDs on your own - use a GUID and you can be sure that it's unique and you have its value before you even insert the row into the database. Regards, mav -- Black holes are the places where god divided by 0...