mljonzs
Posts: 124
|
| Posted: 01/17/2007, 7:54 AM |
|
I am trying to insert data into one table right after updating a different table. I have a couple of other applications where I do similar activity in the After ExecuteUpdate Event and it works fine, but this time I cannot get it to work and I am wondering if it is my SQL (which works directly in SQL Server but maybe doesn't work through CodeCharge??
Here's the Code: Function QUOTE_HEADER_DataSource_AfterExecuteUpdate(Sender) 'QUOTE_HEADER_DataSource_AfterExecuteUpdate @2-63EC357D
'Custom Code @52-73254650
' -------------------------
' Write your own code here.
' -------------------------
'Log data into Tracking/History table
Dim sql
sql = "INSERT QH_History " _
& "SELECT * FROM QUOTE_HEADER " _
& "WHERE QUOTE_NUMBER = " & DBOnlinePO.ToSQL(Request.QueryString("q"),ccsInteger)
DBOnlinePO.Execute(sql)
'End Custom Code
End Function 'Close QUOTE_HEADER_DataSource_AfterExecuteUpdate @2-54C34B28
I have also tried without using the ToSQL function as follows:
Function QUOTE_HEADER_DataSource_AfterExecuteUpdate(Sender) 'QUOTE_HEADER_DataSource_AfterExecuteUpdate @2-63EC357D
'Custom Code @52-73254650
' -------------------------
' Write your own code here.
' -------------------------
'Log data into Tracking/History table
Dim sql
sql = "INSERT QH_History " _
& "SELECT * FROM QUOTE_HEADER " _
& "WHERE QUOTE_NUMBER = " & Request.QueryString("q")
DBOnlinePO.Execute(sql)
'End Custom Code
End Function 'Close QUOTE_HEADER_DataSource_AfterExecuteUpdate @2-54C34B28
I do not get any errors but the data isn't getting put into the QH_History table either? Am I just placing this code in the wrong event?? I want to insert this data AFTER the QUOTE_HEADER table has stored any updates.
Please help!
Thanks!
_________________
What does not begin WITH God, will end in failure!
|
 |
 |
mljonzs
Posts: 124
|
| Posted: 01/17/2007, 1:41 PM |
|
After much messing around with this, I have been able to get the results I wanted by using a CustomUpdate on the QUOTE_HEADER record as follows:
UPDATE QUOTE_HEADER SET UPDATED_USER='{UpdatedUser}', LAST_UPDATED='{UpdatedDate}', PO_NUMBER='{PO_NUMBER}', PRICELIST='{PRICELIST}', EXPECT_DELIV_DATE='{EXPECT_DELIV_DATE}', DEALER_CONTACT_NAME='{DEALER_CONTACT_NAME}', DEALER_CONTACT_EMAIL='{DEALER_CONTACT_EMAIL}', DEALER_CONTACT_PHONE='{DEALER_CONTACT_PHONE}' WHERE QUOTE_NUMBER = {q}
INSERT QH_History
SELECT * FROM QUOTE_HEADER
WHERE QUOTE_NUMBER = {q}
I removed the AfterExecuteUpdate code and just used the CustomUpdate. Anyone know why this works but the Code in AfterExecuteUpdate shown above does not??
Thanks!
_________________
What does not begin WITH God, will end in failure!
|
 |
 |
mljonzs
Posts: 124
|
| Posted: 01/18/2007, 6:52 AM |
|
Okay, I was told by support NOT to use multiple queries in the Custom Update/Insert. Anyone know why this would be? It worked just fine??
Also, they found the problem with my original project. I had somehow modified the BindEvents method in the events.asp page of the Code Charge project so my AfterExecuteUpdate event was never fired. This makes LOTS of sense! I'm correcting that now and checking to see if it works....
Yes, it does work. Go figure!
_________________
What does not begin WITH God, will end in failure!
|
 |
 |
|