The code is below. in my code I updating existing row(from existing table) that the program get all the updated values from textBoxes. there is at the end(the last column)of the
I'd suggest moving the query from inline sql to a stored procedure. Not so much to stop SQL injection but because you can set the stored procedure to return the value of the identity (autonumber) field its just created. simply have it return SCOPE_IDENTITY after running the sql.
all that is assuming you are using SQL server (I'm not familiar with other db's but would assume they have similar functionality)
see link for more info
http://msdn.microsoft.com/en-us/library/ks9f57t0.aspx
EDIT: WOW this was answered fast! apologies for duplicate answers
EDIT2: looks like access exposes a variable @@IDENTITY that contains the last used/created autonumber. so you should be able to run and inline query and follow it with another along the lines of 'SELECT @@IDENTITY AS prevID'
see this:
http://msdn.microsoft.com/en-us/library/ks9f57t0(v=VS.80).aspx
See the section labeled "Retrieving Microsoft Access Autonumber Values"
sort version
OleDbCommand cmdNewID = new OleDbCommand("SELECT @@IDENTITY",
connection)
I do not believe SCOPE_IDENTITY() exist in access