Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored procedure for edit log
Message
From
19/11/2008 12:24:50
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01361756
Message ID:
01362865
Views:
8
>>>>>Hi Viv,
>>>>>
>>>>>I guess you meant this one Re: Pass a web variable to a stored procedure Thread #1257541 Message #1258431
>>>>
>>>>Thanks Viv,
>>>>and
>>>>Thanks Naomi. Your memory and search ability is amazing. I truly do get embarrassed when an answer to a question turns up to be one of my previous threads. (This may actually be my 3rd go at this. In the prior case I learned how to solve the previous problem but not enough to carry it forward to my new situation. Let's review and see if it will work in the new environment. The assignment is to create an edit log that preserves date, user, old and new values, etc. The code to do this is in a stored procedure that executes via INSERT and UPDATE triggers. The reason it is by trigger is that the edits may happen any one of 3 ways, the VFP UI Browse, the VFP application, the web (.NET). So the SP looks like this
>>>>func SaveHistory()
>>>>lparam lcTriggerType
>>>>** more code and  do the save etc
>>>>INSERT INTO historylog (editdate,user,etc) values (datetime(),gcUserName,etc)
>>>>
>>>>and the triggers look like this:
>>>>
>>>>*Update Trigger
>>>>SaveHistory("U")
>>>>*Insert Trigger
>>>>SaveHistory("I")
>>>>
>>>>This works fine from the VFP side. Now lets go to the NET side. We have an SqlDatasource using an OLEDB connection, and a Formview using the SqlDatasource. The user clicks the Formview into edit mode,makes the edits, and then clicks Save/Update which fires the SqlDataSource UpdateCommand. Assuming I can programmatically define the UpdateCommand, how can I embed the value of Session("User") so that the SP can see it?
>>>>Note that the SP is not fired from NET. It is fired inside VFP by the trigger.
>>>
>>>Hi,
>>>
>>>I didn't remember that you were the one who'd asked the question before !
>>>Anyway the message that Naomi referenced pretty much covers it:
>>>Pass in the value you want to use for gcUserName when you are creating the connection. When the trigger fires the SP it should pick up the value as it normally would.
>>>
>>>Shout if you have problems....
>>>Best,
>>>Viv
>>
>>Naomi and Viv -
>>Thanks
>>The light is beginning to flicker on.
>>If I understand right, what you have suggested is to find a way to execute these 2 commands
>>
>>public gcEmployee
>>gcEmployee = 'myname'
>>
>>via the OLEDB connection sometime before the trigger is fired. The value of gcEmployee should then remain available to any subsequent activity as long as the connection remains open. Correct? If this is the case I can understand how the previous code suggestion would work. In my case however I don't have an oConn to work with explicitly. What I have is SQLDataSource1 which handles its connection internally. So I tried this approach
>>
>>Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
>>    SqlDataSource1.UpdateCommand = "Public gcEmployee" + Chr(13) + Chr(10) + "gcEmployee = 'Viv'" + Chr(13) + Chr(10) +  SqlDataSource1.UpdateCommand
>>End Sub
>>
>>
>>But this didn't work. Perhaps the placement of the code is wrong. Any more insights?
>
>Instead of trying to change UpdateCommand in code, can you just place this code there when you configure DataSource or in ASPX code ?

Something is wrong with your last message. It does not load fully. However I got the text. What I meant was, do you know of a way to obtain a reference to the connection being used by a SqlDatasource so I can implement Viv's original suggestion?

Second, I DID try putting the code directly in the aspx markup. That was the point of my last post. The syntax checker didn't like it and it wouldn't build.
:)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform