Can not use KILL to kill your own process

kryankerkryanker Member Posts: 14
edited 2010-04-01 in SQL General
Hello,

My customer had requested a customization which will auto log off a Navision Idle session if number of user sessions is exceeded from the license allowed. This customization is done on NAV2009 sql server option. I had tried on using a SQL automation ('Microsoft SQLDMO Object Library'.SQLServer) to kill the process from SQL server since deletion of record on Navision Session table is not working. Below is my part of coding on using the automation to kill the process:
        IF NOT ISCLEAR(autoSQL) THEN
          CLEAR(autoSQL);
        CREATE(autoSQL);
        autoSQL.Connect(MYSERVER,MYUSERID,MYPASSWORD);
        autoSQL.KillProcess(Session."Connection ID");
        autoSQL.Close;

I was placed these code in Codeunit 1 ApplicationManagement, and trigger on LogInStart() function. Which I thinking to check session table for the idle session and kill it while login as a new session. The problem is my coding getting a run time error which shown below and the session is not killed.

The following SQL Server error or errors occurred:

6104,"42000",[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot use KILL to kill your own process.


Can anyone advice me on this my idea? Or any suggestion on this auto log off customization?

Thank you.

Comments

  • kinekine Member Posts: 12,562
    I suggest to use NAS to do that (NAV cApplication Server) which will check the session and kill them if needed.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • garakgarak Member Posts: 3,263
    or try this ;-)

    viewtopic.php?f=5&t=31486
    Do you make it right, it works too!
  • kryankerkryanker Member Posts: 14
    Thanks for the replies, I will try working on yours suggestion. :wink:
  • pdjpdj Member Posts: 643
    I was surprised that your code didn't work, so I tried making a simular example which works fine:
    Report - OnPreReport()
    Session.SETRANGE("My Session",TRUE);
    Session.FINDFIRST;
    CREATE(SQLServer);
    SQLServer.LoginSecure := TRUE;
    SQLServer.Connect('MY-PC');
    SQLServer.KillProcess(Session."Connection ID");
    SQLServer.DisConnect;
    
    Don't quite see the difference... :-k
    Regards
    Peter
  • kryankerkryanker Member Posts: 14
    Thanks to all replies again. :wink:

    Here I continue my topic.

    reply to pdj,
    Yes, is no difference. But :oops: is my own mistake, I used the automation KillProcess after I delete the session record. So it point back to the own process when I trigger the KillProcess. (that's why it prompt me can not kill myself :lol: )
    thanks to pdj

    #-o but after I had solved this problem, another problem come out. I noticed that delete the record from session table is equal with using automation to kill the process. Do either one will be enough to meet my requirement.

    :cry: but my case difference, normally (is it? :-k ) when user access the NAV screen which already process killed will be prompted an error about the connection. Then user will need to login again to a new session to access NAV.

    ](*,) I had tried many times of it and the session has "revive" when user access back to the killed session. Is that because of I was using SQL Server 2008 on the server? Or this should not be the correct way to kill the navision SQL session? Or any suggestion how to closed the NAV windows which process get killed?
  • selece28selece28 Member Posts: 316
    Hi kryanker,

    I'm also having the same problems, i'm using sql server 2008. After the connection of a user is terminated, when that user click it create / revive the session again?
    Its weird, is there anything to set to permanently kill that session and force the user to login again?

    Thanks
    ______________

    Regards,
    Steven
  • kinekine Member Posts: 12,562
    I think that this is question of NAV client version. It seems that since som build of NAV 5.00SP1 the connection is re-established when user need it.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rdebathrdebath Member Posts: 383
    Of course if you want the client to disappear you could try this piece of code ...
    OBJECT Codeunit 99903 Crash Navision
    {
      OBJECT-PROPERTIES
      {
        Date=26/08/09;
        Time=15:39:07;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        OnRun=VAR
                CU@1000000000 : Codeunit 99903;
              BEGIN
                CU.RunTask(CU);
    
                MESSAGE('Didn''t crash');
              END;
    
      }
      CODE
      {
    
        PROCEDURE RunTask@1000000000(VAR Self@1000000000 : Codeunit 99903);
        BEGIN
          CLEAR(Self);
        END;
    
        BEGIN
        END.
      }
    }
    
    In truth, it's not something Microsoft is going to find easy to fix.
Sign In or Register to comment.