⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdb.cpp

📁 用ODBC写的数据库接口,支持SQlserver,mysql
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->ExecSQL(szSQL,callback);
    return false;
}


bool  __stdcall WDB_ExecSQLFile(HANDLE pHandle,char * szSQLFile,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->ExecSQLFile(szSQLFile,callback);
    return false;
}


bool __stdcall WDB_Query(HANDLE pHandle,char * szSQL)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Query(szSQL);
    return false;
}

int __stdcall  WDB_RecordCount(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->RecordCount();
    return false;
}

bool __stdcall WDB_First(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->First();
    return false;
}

bool __stdcall WDB_Next(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Next();
    return false;
}

char *__stdcall WDB_GetDataValue(HANDLE pHandle,char *szFieldName,int *len)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(len)
        *len = 0;
    if(pFace)
    {
        if(len)
            return pFace->GetDataValue(szFieldName,len);
        else
        {
            int mylen;
            return pFace->GetDataValue(szFieldName,&mylen);
        }
    }
    return NULL;
}

int  __stdcall WDB_GetIntValue(HANDLE pHandle,char *szFieldName)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    //*len = 0;
    if(pFace)
        return pFace->GetIntValue(szFieldName);
    return 0;
}

char *__stdcall WDB_GetValueByIdx(HANDLE pHandle,int idx,int *len)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(len)
        *len = 0;
    if(pFace)
        return pFace->GetValueByIdx(idx,len);
    return NULL;
}

int  __stdcall WDB_GetIntByIdx(HANDLE pHandle,int idx)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->GetIntByIdx(idx);
    return 0;
}

void  __stdcall WDB_AddSQL(HANDLE pHandle,char *sql)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        pFace->AddSQL(sql);
}

bool   __stdcall WDB_SetParam(HANDLE pHandle,char *parm,char *value,int size,int type)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->SetParam(parm,value,size,type);
    return 0;
}

bool   __stdcall WDB_RunSql(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->RunSql();
    return 0;
}

/*bool   __stdcall WDB_GetFields(HANDLE pHandle,char *Fields,int *memsize,int *count)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->GetFields(Fields,memsize,count);
    return 0;
}*/

bool   __stdcall WDB_BeginTrans(HANDLE pHandle,int *outLevel)
{
//    return true;
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->BeginTrans(outLevel);
    return 0;
}

bool   __stdcall WDB_Commit(HANDLE pHandle)
{
//    return true;
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Commit();
    return 0;
}

bool   __stdcall WDB_Rollback(HANDLE pHandle)
{
//    return true;
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Rollback();
    return 0;
}

bool   __stdcall WDB_LockTables(HANDLE pHandle,char *tables)
{
//    return true;
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->LockTables(tables);
    return 0;
}

bool   __stdcall WDB_UnlockTables(HANDLE pHandle,char *tables)
{
//    return true;
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->UnlockTables(tables);
    return 0;
}

HANDLE __stdcall WDB_BatchBegin(HANDLE pHandle,char *szTable,char *Fields)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->BatchBegin(szTable,Fields);
    return NULL;
}

bool __stdcall WDB_BatchAdd(HANDLE pHandle,HANDLE hdBatchHandle,char *szValues,int type,int ValueLen,bool endline)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->BatchAdd(hdBatchHandle,szValues,type,ValueLen,endline);
    return 0;
}

bool __stdcall WDB_BatchEnd(HANDLE pHandle,HANDLE hdBatchHandle,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->BatchEnd(hdBatchHandle,callback);
    return 0;
}

bool   __stdcall WDB_BatchFree(HANDLE pHandle,HANDLE hdBatchHandle)
{
    DB_BATCH_INFO *pDbBatchInfo = (DB_BATCH_INFO *)hdBatchHandle;
    if(pDbBatchInfo)
    {
        if(pDbBatchInfo->fp)
        {
            fclose(pDbBatchInfo->fp);
            pDbBatchInfo->fp = NULL;
        }
        DeleteFile(pDbBatchInfo->tmpFile);
        if(pDbBatchInfo->pData)
            free(pDbBatchInfo->pData);
        delete  pDbBatchInfo;
    }
    return true;
}

bool __stdcall WDB_BatchByFile(HANDLE pHandle,char *sFileName,int filetype,char *szTableName,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->BatchByFile(sFileName,filetype,szTableName,callback);
    return 0;
}

bool  __stdcall WDB_FetchToFile(HANDLE pHandle,char *sql,char *pathname,char *szTable,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->FetchToFile(sql,pathname,szTable,callback);
    return 0;
}

bool   __stdcall WDB_OptimizeTable(HANDLE pHandle,char *tables)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->OptimizeTable(tables);
    return 0;
}

bool   __stdcall WDB_Backup(HANDLE pHandle,char *pathname,char *db,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Backup(pathname,db,callback);
    return 0;
}

bool   __stdcall WDB_Restore(HANDLE pHandle,char *pathname,char *dbname,void *callback)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->Restore(pathname,dbname,callback);
    return 0;
}


char    *__stdcall WDB_GetField(HANDLE pHandle,int idx)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->GetField(idx);
    return 0;
}

int     __stdcall WDB_FieldCount(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->FieldCount();
    return 0;
}


int     __stdcall WDB_EscapeString(char *from ,char *to ,int fromlen)
{
    return 0;//mysql_escape_string(to,from,fromlen);
}


char*   __stdcall WDB_GetErr(HANDLE pHandle)
{
    CDBFaceBase *pFace = (CDBFaceBase *)pHandle;
    if(pFace)
        return pFace->GetErr();
    return "句柄是空指针";
}



/*
bool GetDSN(char *pDSN,char *pHost)
{
HKEY hKey;
int re;
//char str[120]={0};
char key[1024];
DWORD type,lpcbData=50 ;
    sprintf(key,"Software\\ODBC\\ODBC.ini\\%s",pDSN);
    re=RegOpenKeyEx(HKEY_LOCAL_MACHINE,
            key,0,KEY_ALL_ACCESS,
            &hKey);
    if(re==ERROR_SUCCESS)
    {
        re = RegQueryValueEx(hKey,
                    "Server",
                    NULL,
                    &type,
                    pHost,
                    &lpcbData);
        if(re==ERROR_SUCCESS)
        {
            RegCloseKey(hKey);
            return true;
        }
    }
    RegCloseKey(hKey);
//  return 0;
    //if(str[0]=='1')
    //    return 1;
    return false;
}

*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -