Уроки Iczelion'а


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


DlgProc proto hDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD QueryProc proto hDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD SwitchMenuState proto :DWORD ODBCConnect proto :DWORD ODBCDisconnect proto :DWORD RunQuery proto :DWORD

.data? hInstance dd ? hEnv dd ? hConn dd ? hStmt dd ? Conn db 256 dup(?) StrLen dd ? hMenu dd ? ; handle to the main menu hList dd ? ; handle to the listview control TheName db 26 dup(?) TheSurname db 26 dup(?) TelNo db 21 dup(?) NameLength dd ? SurnameLength dd ? TelNoLength dd ? SearchName db 26 dup(?) ProgPath db 256 dup(?) ConnectString db 1024 dup(?)

.data SQLStatement db "select * from main",0 WhereStatement db " where name=?",0 strConnect db "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=",0 DBName db "test.mdb",0 ConnectCaption db "Complete Connection String",0 Disconnect db "Disconnect successful",0 AppName db "ODBC Test",0 AllocEnvFail db "Environment handle allocation failed",0 AllocConnFail db "Connection handle allocation failed",0 SetAttrFail db "Cannot set desired ODBC version",0 NoData db "You must type the name in the edit box",0 ExecuteFail db "Execution of SQL statement failed",0 ConnFail db "Connection attempt failed",0 AllocStmtFail db "Statement handle allocation failed",0 Heading1 db "Name",0 Heading2 db "Surname",0 Heading3 db "Telephone No.",0

.code start: invoke GetModuleHandle, NULL mov hInstance,eax call GetProgramPath invoke DialogBoxParam, hInstance, IDD_MAINDLG,0,addr DlgProc,0 invoke ExitProcess,eax invoke InitCommonControls DlgProc proc hDlg:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD .if uMsg==WM_INITDIALOG invoke GetMenu, hDlg mov hMenu,eax invoke GetDlgItem, hDlg, IDC_DATALIST mov hList,eax call InsertColumn .elseif uMsg==WM_CLOSE invoke GetMenuState, hMenu, IDM_CONNECT,MF_BYCOMMAND .if eax==MF_GRAYED invoke ODBCDisconnect, hDlg .endif invoke EndDialog,hDlg, 0 .elseif uMsg==WM_COMMAND .if lParam==0 mov eax,wParam .if ax==IDM_CONNECT invoke ODBCConnect,hDlg .elseif ax==IDM_DISCONNECT invoke ODBCDisconnect,hDlg .elseif ax==IDM_QUERY invoke RunQuery,hDlg .elseif ax==IDM_CUSTOMQUERY invoke DialogBoxParam, hInstance, IDD_QUERYDLG,hDlg, addr QueryProc, 0 .endif .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret DlgProc endp




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



Книжный магазин