Уроки Iczelion'а


Урок 5. ODBC пример - часть 3


GetProgramPath proc invoke GetModuleFileName, NULL,addr ProgPath,sizeof ProgPath std mov edi,offset ProgPath add edi,sizeof ProgPath-1 mov al,"\" mov ecx,sizeof ProgPath repne scasb cld mov byte ptr [edi+2],0 ret GetProgramPath endp

SwitchMenuState proc Flag:DWORD .if Flag==TRUE invoke EnableMenuItem, hMenu, IDM_CONNECT, MF_GRAYED invoke EnableMenuItem, hMenu, IDM_DISCONNECT, MF_ENABLED invoke EnableMenuItem, hMenu, IDM_QUERY, MF_ENABLED invoke EnableMenuItem, hMenu, IDM_CUSTOMQUERY, MF_ENABLED .else invoke EnableMenuItem, hMenu, IDM_CONNECT, MF_ENABLED invoke EnableMenuItem, hMenu, IDM_DISCONNECT, MF_GRAYED invoke EnableMenuItem, hMenu, IDM_QUERY, MF_GRAYED invoke EnableMenuItem, hMenu, IDM_CUSTOMQUERY, MF_GRAYED .endif ret SwitchMenuState endp

ODBCConnect proc hDlg:DWORD invoke SQLAllocHandle, SQL_HANDLE_ENV, SQL_NULL_HANDLE, addr hEnv .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO invoke SQLSetEnvAttr, hEnv,SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3,0 .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO invoke SQLAllocHandle, SQL_HANDLE_DBC, hEnv, addr hConn .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO invoke lstrcpy,addr ConnectString,addr strConnect invoke lstrcat,addr ConnectString, addr ProgPath invoke lstrcat, addr ConnectString,addr DBName invoke SQLDriverConnect, hConn, hDlg, addr ConnectString, sizeof ConnectString, addr Conn, sizeof Conn,addr StrLen, SQL_DRIVER_COMPLETE .if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO invoke SwitchMenuState,TRUE invoke MessageBox,hDlg, addr Conn,addr ConnectCaption, MB_OK+MB_ICONINFORMATION .else invoke SQLFreeHandle, SQL_HANDLE_DBC, hConn invoke SQLFreeHandle, SQL_HANDLE_ENV, hEnv invoke MessageBox, hDlg, addr ConnFail, addr AppName, MB_OK+MB_ICONERROR .endif .else invoke SQLFreeHandle, SQL_HANDLE_ENV, hEnv invoke MessageBox, hDlg, addr AllocConnFail, addr AppName, MB_OK+MB_ICONERROR .endif .else invoke SQLFreeHandle, SQL_HANDLE_ENV, hEnv invoke MessageBox, hDlg, addr SetAttrFail, addr AppName, MB_OK+MB_ICONERROR .endif .else invoke MessageBox, hDlg, addr AllocEnvFail, addr AppName, MB_OK+MB_ICONERROR .endif ret ODBCConnect endp




- Начало -  - Назад -  - Вперед -