SQL Server Performance

Problem: Can dhcp callout dll insert new row into

Discussion in 'General Developer Questions' started by quesxion, Feb 2, 2006.

  1. quesxion New Member

    I current working on this dll, but i found the dll doesn't response to any of the cdatabase execute response? I have try all the cdatabase and sql in c++ console and found that it can be run. The database is open success and the sql statement is correct.

    After then i put it into the dhcp callout dll, and compile success.

    When i add it into the registry and try the dhcp server, it doesn't have any response database table. And i using sql server for the dsn.

    Here is my code

    #include "stdafx.h"
    #include "callout.h"

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif

    CDatabase dbCallout;

    struct tm *newtime;
    char am_pm[] = "AM";
    __time64_t long_time;

    CString strCmd, strPrimaryKey, strTime;
    int nRetCode = 0;

    BOOL APIENTRY DllMain( HANDLE hModule,
    DWORD ul_reason_for_call,
    LPVOID lpReserved )
    {
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
    break;
    case DLL_THREAD_ATTACH:
    break;
    case DLL_THREAD_DETACH:
    break;
    case DLL_PROCESS_DETACH:
    break;
    } return TRUE;
    }

    DWORD CALLBACK DhcpControlHook(DWORD dwControlCode,LPVOID lpReserved)
    {
    switch (dwControlCode)
    {
    case DHCP_CONTROL_START: {
    _time64( &long_time ); /* Get time as long integer. */
    newtime = _localtime64(&long_time); /* Convert to local time. */

    if( newtime->tm_hour > 12 ) /* Set up extension. */
    strcpy( am_pm, "PM" );
    if( newtime->tm_hour > 12 ) /* Convert from 24-hour */
    newtime->tm_hour -= 12; /* to 12-hour clock. */
    if( newtime->tm_hour == 0 ) /*Set hour to 12 if midnight. */
    newtime->tm_hour = 12;

    strPrimaryKey.Format("C%.2d%.2d%.2d%.2d%.2d%.2d", newtime->tm_year - 100, newtime->tm_mon, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
    strTime = asctime(newtime);

    strCmd = "INSERT INTO Callout_Control (control_id, control_desc, control_date) VALUES ('" + strPrimaryKey + "', 'DHCP server have started!', '" + strTime + "')";

    dbCallout.ExecuteSQL(strCmd);
    dbCallout.Close();

    break;
    }
    case DHCP_CONTROL_STOP:
    {

    break;
    }
    case DHCP_CONTROL_PAUSE:
    {

    break;
    }
    case DHCP_CONTROL_CONTINUE:
    {
    break;
    }
    }
    return ERROR_SUCCESS;
    }

    DWORD CALLBACK DhcpServerCalloutEntry(LPWSTR ChainDlls,DWORD CalloutVersion,LPDHCP_CALLOUT_TABLE CalloutTbl)
    {

    CalloutTbl->DhcpAddressDelHook=DhcpAddressDelHook;
    CalloutTbl->DhcpControlHook=DhcpControlHook;
    CalloutTbl->DhcpDeleteClientHook=DhcpDeleteClientHook;
    CalloutTbl->DhcpPktDropHook=DhcpPktDropHook;
    CalloutTbl->DhcpAddressDelHook=DhcpAddressDelHook;
    CalloutTbl->DhcpNewPktHook=DhcpNewPktHook;
    CalloutTbl->DhcpPktSendHook=DhcpPktSendHook;

    dbCallout.Open(_T("CALLOUT"), FALSE, FALSE, _T("ODBC;"));

    return ERROR_SUCCESS;
    }

    What wrong in this code? Can dll file insert new row into dsn? Some expert please help me!!!

Share This Page