Note that there are some explanatory texts on larger screens.

plurals
  1. POAble to Update New Data in One Column But Not Able to Store Old Data in Another
    primarykey
    data
    text
    <p>I posted a question 4 months ago at <a href="https://stackoverflow.com/questions/7336786/store-old-data-in-one-column-and-update-new-data-in-another-column-within-same-t/9131237#9131237"><a href="https://stackoverflow.com/questions/7336786/store-old-data-in-one-column-and-update-new-data-in-another-column-within-same-t/9131237#9131237">Store old data in one column and update new data in another column within same table</a></a>.</p> <p>Now, I'm working on the codes again and here is my problem. After I clicked the "Update" button on the web page, the <strong>old</strong> (previous) LastName did not store in the <strong>Alias</strong> column. In fact, the <strong>new</strong> LastName is stored in both <strong>LastName</strong> (for new LastName) and <strong>Alias</strong> (supposedly for previous LastName) columns. I need the <strong>old</strong> LastName to be kept in the <strong>Alias</strong> column. Please review below and see what I did wrong. Thanks in advance!</p> <p><strong>Stored Procedure</strong></p> <pre><code>ALTER PROCEDURE [dbo].[KeepAliasName] @PeopleID int, @LastName varchar(25) AS BEGIN UPDATE People SET Alias = LastName, LastName = @LastName WHERE CAST(PeopleID AS Varchar(25)) = @PeopleID END </code></pre> <p><strong>Codes that call the Stored Procedure</strong></p> <pre><code>Dim oCmd1 Dim ln Dim retCount Set oCmd1 = Server.CreateObject("ADODB.Connection") Set oCmd1 = Server.CreateObject("ADODB.Command") ''' EXECUTE THE COMMAND TO CREATE THE RECORDSET With oCmd1 .ActiveConnection = Connect .Commandtext = "KeepAliasName" .CommandType = adoCmd1StoredProc .Parameters.Append .CreateParameter("@PeopleID", adInteger, adParamInput, 25) .Parameters("@PeopleID") = pID 'some Employee you get from your code .Parameters.Append .CreateParameter("@LastName", adVarChar, adParamInput, 25) .Parameters("@LastName") = lastnameVal 'some Employee's name you get from your code .Execute ln, , adExecuteNoRecords End With Set oCmd1 = Nothing </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload