views:

34

answers:

1

Hi Everyone. i've installed SQL Server 2008 R2 On my machine (my machine runs windows server 2003) some of the tables inside my db are fireing triggers (when insert,delete,update occurs) the trigger result supposed to reach some process (triggersReceiver.exe via shared memory) that waits for the triggers. the problem is that the SQL Server 2008 r2 does not recognize this process the error i get when trigger fires: triggersReceiver.exe is not running . but he is runing !!!!! is any one faced a similiar problem before ??

This is the code that of the "connector dll" the part that executes when ever a trigger is fired (this code executes via extended stored procedure): all the functionality is found in winbase.h (windows dll)

////////Defenitions///////////////////////////////////////////////////////
#define XP_TRIGGER_SHARED_MEMEORY   L"Global\\xp_trigger_shared_memory"
#define XP_TRIGGER_PROCESS_EVENT    L"Global\\xp_trigger_process_event"
#define XP_TRIGGER_DONE_EVENT        L"Global\\xp_trigger_done_event"
////////////////////////////////////////////////////////////////////////////

this function returns FALSE (i dont know why...)

BOOL CTriggerGatewayConnector::Init()
{
::InitializeCriticalSection(&m_CS);

m_hMap = ::OpenFileMappingW(FILE_MAP_WRITE, FALSE, XP_TRIGGER_SHARED_MEMEORY);
if (m_hMap == NULL)
{

    return FALSE;
}

m_pSqlTrigInfo = (SqlTriggerInfo*)::MapViewOfFile(
                    m_hMap, FILE_MAP_WRITE, 0, 0,sizeof  (SqlTriggerInfo));
if (m_pSqlTrigInfo == NULL)
{
    return FALSE;
}

m_hProcess = ::CreateEventW(NULL, FALSE, FALSE, XP_TRIGGER_PROCESS_EVENT);
if (m_hProcess == NULL)
{
    return FALSE;
}

m_hDone = ::CreateEventW(NULL, FALSE, FALSE, XP_TRIGGER_DONE_EVENT);
if (m_hDone == NULL)
{
    return FALSE;
}

return TRUE;
}

Thnanks, Liran.

A: 

The Problem Solved!!! It Actually was a permission problem. when the trigger fired it tries to write to the file XP_TRIGGER_SHARED_MEMEORY And It Failed Here : m_hMap = ::OpenFileMappingW(FILE_MAP_WRITE, FALSE, XP_TRIGGER_SHARED_MEMEORY); if (m_hMap == NULL) { return FALSE; } the trigger actually activated the dll that was loaded to the sql server, and the Sql server does not have any permission (teven through the dll inside it) to write to ahe shard file.

in order to solve it you need to give sql server the permmisions: Right Click on MyComputer ->Manage ->Services And Application -> Services : ForEach SQL service : (in the list on the right) 1. Right Click On It -> Properties -> LogOn Tab ->change to Local System Account.

Hope it will help somtime..

Liran