Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stored procedure for edit log
Message
De
19/11/2008 12:00:22
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01361756
Message ID:
01362852
Vues:
13
>>>>>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 ?

That would equate to something like this
UpdateCommand="Public employee" + Chr(13) + Chr(10) + "employee = [Viv]" + "UPDATE rtp_projects SET rtp_id = ?, tip_id = ?, lead = ?, st_name = ?, termini = ?, project = ?, length = ?, detail_des = ?, category = ?, system = ?, subsystem = ?, existlanes = ?, newlanes = ?, est_start = ?, est_finish = ?, newbikelan = ?, multiuse = ?, newwalks = ?, study = ?, design = ?, rw = ?, const = ?, operations = ?, total_cost = ? WHERE keyid = ? ">
in the SqlDatasource definition. The syntax checker takes exception to the portion [+ chr(10)].
Do you know of a way to get a hook to the SqlDatasource connection?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform