• vincentshanecurtis - Wednesday, August 23, 2017 7:16 AM

    Data Source=.\SQLEXPRESS;AttachDbFilename=E:\Yu-Gi-Oh\db\Yu-Gi-OhCardsDBSQL.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
    This is the connection string used by my app.

    Integrated Security=True;
    So it's connecting as the windows user you're logged in as.
    What  permissions does that login have on the SQL Express instance?

    If there were a permissions issue wouldn't I be getting some type of error message?  When the SPs are executed separately from the client app they work.  Records get updated.  When they get executed from the driver SP nothing happens.  Makes no sense to me. 

    You should be getting an error, yes. It's not a fatal error though, it doesn't abort the batch or the session, so without error handling you might not notice you're getting an error. Without sufficient permissions, the function doesn't return useful values though, and hence the code inside the IF blocks won't execute.
    https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-tran-active-transactions-transact-sql

    Yes, the stored procs will execute individually, there's nothing wrong with the individual stored procedures. The problem is that udf_TransactionExists() does not check whether that session has an open transaction. It checks the server-level DMV to see whether there are *any* transactions named 'Add' or 'Edit' at all, from any of the running sessions, and without sufficient permission, won't return what's expected. same with the other two functions that check for transactions

    And it still doesn't address my initial question in this post do the two pieces of code accomplish the same thing? 

    No, they don't.

    The first executed the insert code if that user has added a record and the update code if the user has edited a record

    The second checks to see whether anyone using the server has a transaction named add, and if so it inserts a record. If no one on the server has a transaction named add, and anyone on the server has a transaction named edit, then it updates the row. If it has insufficient permissions to check that, it does nothing at all.

    Unfortunately I can't seem to get anywhere using Server's debugger so I can't step through my code to see what's happening or not happening.

    The debugger's a right bloody pain, and requires sysadmin access which means it seldom gets used. More normally we use PRINT to debug, or insert into logging tables or stuff like that. PRINT requires that you're running from Management Studio, or are looking for the messages being returned from the server (and I have no idea how to do that in VB)

    My design may be poor but this is my FIRST attempt at doing ANYTHING of real substance with Server and it's a learning experience.  I'm sorry I don't measure up to your standards.

    You can take what I said (here and last time you asked about this) as an accusation, or you can take it as things to improve. Your choice.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass