Thanks. I was not sure if Rick had an ADO call to update an identity column on an insert, but @@IDENTITY was my back-up plan. I have used @@IDENTITY going back to SQL 6.5 and I am only adding one row at a time.
Question: Why do you reload the new row, after getting the identity value? Is that to return any default values? I am just wondering because it does not seem like it will help me as far as the identity column goes, since it is a stateless app.
Since Web apps are stateless, the next button click will have to reload the row. However, I want to make sure that I don't reload a row or insert a new row, based on a URL parameter. I was thinking of using a session variable to store the identity value and another session variable to store the operation. So, I add a contact. Now, I want to add an order. When I click the button to add the order, look at the session variable, rather than the URL parameter.
Thanks,
David
Hi David;
I have been using SQL Server with a number of applications.
I have subclassed the wwsql class and modified a few of the methods.
Specifically saving data (I have columns that can have default null values, or have a default value like GETDATE() and so my code specifically will not include those fields
on an insert if the value is null. Also, getting back the primary key is valuable too!)
Anyway, here is the sub-classed code of my save method.
Note that after the save of data, I do a specific call to the load method with the primary key to
load the oData object with the values just saved, including the primary key.
The buildrecordinfo is an extra method I added for cases where I wanted to display the date and time of the last edit
(pretty well all my tables have columns for who created the record, when it was created, who modified and when modified.
These date fields are updated by a triggers)
I should be using Scope_Identity() instead of @@Identity but as long as inserts don't add records in other tables I am okay.
But I should update this. (This code has been in place for years!)
Bob
Hi,
I am going to use a wwBusiness subclass to connect to an MS SQL table, which has an identity (auto increment) primary key column. I am using wwSQL to connect to the SQL server. I assume that I have to specify the PK column for cSkipFieldsForUpdates. When I insert a new row, the PK column will not have a value. When I save the row, will the wwBusiness class refresh the identity value or do I have to make a call to @@IDENTITY?
Thanks,
David