Gladimir Posted April 23, 2003 Posted April 23, 2003 I have a table whose sole purpose is to store the last masterID and lastTempID numbers used in other tables. So, the table only has a single row of data two columns wide. The first column holds the lastMasterID and the second column holds the lastTempID. The application contains various functions that process hundreds of thousands of rows of input tables. These functions might need to get and set the lastMasterID or the lastTempID depending on whether or not new data is found in the input tables. What is the best / slickest way to setting this up? I was simple making two public functions called getlastMasterID and getlastTempID that returns the value of the corresponding field. However, I think a public class that allows me to get and set in the same function might be more efficient (if I am using the correct terminology). Either way, do I simply create the necessary connection and adapter objects and populate a dataset using the adapter's Fill method? Or is that way too much overhead for what I need to do? Quote Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
*Experts* Nerseus Posted April 23, 2003 *Experts* Posted April 23, 2003 I would use a DataReader for this, if you really need to know the IDs in your client application. You'll definitely want to use one SQL statement (a Query in Access or a Stored Proc in SQL Server) to handle both the UPDATE and SELECT, as you'll want to guarantee that you get a unique value. Generally, you don't really need these IDs until you're ready to save, not just when the user clicks a new "New Row" button. It's generally better to not increment your identity values until you actually do an insert. That means you may not even need a class to handle getting an ID - instead, the proc that's going to do an INSERT using a Master or TempID will do the necessary SQL code to UPDATE the master ID table and get the current value. -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.