Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What could cause delete in SQL Serv not work
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01545246
Message ID:
01545265
Views:
32
>>>>>>>Hi,
>>>>>>>
>>>>>>>I use CursorAdapters for inserting/updating/delete data in SQL Server. I have a base class that all tables use. The problem is when I try to delete a record in one of the tables it does not work. I get no error and when I step through the code in debugger everything seem to be normal. But the record in SQL Server never gets deleted. I have checked the code in the CursorAdapter class, method BeforeDelete and it correctly has expression:
>>>>>>>
>>>>>>>delete from TableName where Pk_Fld = ?oldval('Pk_fld','CaViewName')
>>>>>>>
>>>>>>>
>>>>>>>I also checked in the same method that the value of oldVal('pk_fld') is the one I am trying to delete.
>>>>>>>
>>>>>>>When I delete a record from another table (using the same base class), it works.
>>>>>>>
>>>>>>>Where should I look for? In SQL Server? or in my VFP code? TIA.
>>>>>>
>>>>>>
>>>>>>Run SQL Profiler and see what happens at the SQL Server end.
>>>>>
>>>>>Could the line, right before the call to EXEC SP_EXECUTESQL is called, be causing the problem. The line is:
>>>>>
>>>>>
>>>>>set implicit_transaction on
>>>>>
>>>>
>>>>Nope, but as Naomi suggested already copy this code in SSMS and run it.
>>>>Then see what message you will get.
>>>>I saw that you don't have triggers, but did you have FK constraints?
>>>
>>>As I mentioned to Naomi, executing this line in SSMS works; no error. Yet the record is not gone.
>>>I do have FK constraints but there would be an error if the FK would stop the delete, right?
>>
>>Yes, they should be an error.
>>
>>Try:
>>
>>exec sp_executesql N'DELETE FROM EQ_FILE WHERE EQUIP_PK=@P1 ',N'@P1 int',755
>>GO 
>>DELETE FROM EQ_FILE WHERE EQUIP_PK=755
>>GO 
>>SELECT * FROM  EQ_FILE WHERE EQUIP_PK=755
>>GO
>>SELECT DB_NAME()
>>
>
>The record is there and the name of the database is correct. And I tried it with another PK value but with the same result. Record is never deleted. Strange.


HOW about @@TRANCOUNT?
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform