Dear ASM coders,

Good day to all!
I have some question about the ODBC programming
coz I try to connect in *.mdb database then the problem
I cannot connect. Attached file is my sample code.
can you tell me what is wrong in my code.

Thank you in advanced


coredump:stupid:
Posted on 2003-11-14 01:01:12 by coredump
Personally i am not going to download your code and analyze it. Help all of us to help you, post what the error message or number is, and the section of code where you attempt to make the connection. Also post your connection string (you can do all this inline of the message, instead of posting an attachment).
Posted on 2003-11-14 05:16:06 by sluggy
hi coredump,

strConnect db "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=",0

you need a space between 'Driver' and (*.mdb)

strConnect db "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=",0





invoke SQLDriverConnect,hConn,hWnd,addr ConnectString,sizeof ConnectString,addr Conn,sizeof Conn,addr StrLen,SQL_DRIVER_COMPLETE
the problem here is StrLen conflicts with Masm32.lib.



.data?
StringLength2Ptr dd ?


invoke SQLDriverConnect,hConn,hWnd,addr ConnectString,sizeof ConnectString,addr Conn,sizeof Conn,addr StringLength2Ptr,SQL_DRIVER_COMPLETE
Posted on 2003-11-14 11:12:04 by Wayne
hi Wayne,

Thank you for your help and now i got it.
strConnect db "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=",0
just a space and StrLen conflicts.
Thank you..



hi sluggy,
i'm sorry for not displaying the error. next time i will just copy and paste
the error and the code.thank you guys..



regards,
coredump

:alright: :)
Posted on 2003-11-14 18:43:57 by coredump
:)
Follow up question guy,

when I try to build my program there is an error message:
MainWindow.obj : error LNK2001: unresolved external symbol _SwitchMenuState@4
MainWindow.exe : fatal error LNK1120: 1 unresolved externals

what is this error? can anyone explain?

here is my code:

ODBCConnect proto :DWORD
SwitchMenuState proto :DWORD

here is the WM_COMMAND to connect to my database
.ELSEIF uMsg==WM_COMMAND
.IF lParam==0
mov eax,wParam
.if ax==IDM_CONNECT
invoke ODBCConnect,hWnd

.endif
.endif

here is the ODBCConnect:

ODBCConnect proc hWnd: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,hWnd,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,hWnd,addr Conn,addr ConnectCaption,MB_OK+MB_ICONINFORMATION
.ELSEIF
invoke SQLFreeHandle,SQL_HANDLE_DBC,hConn
invoke SQLFreeHandle,SQL_HANDLE_ENV,hEnv
invoke MessageBox,hWnd,addr ConnFail,addr AppName,MB_OK+MB_ICONERROR
.endif
.ELSE
invoke SQLFreeHandle,SQL_HANDLE_ENV,hEnv
invoke MessageBox,hWnd,addr AllocConnFail,addr AppName,MB_OK+MB_ICONERROR
.endif
.ELSE
invoke SQLFreeHandle,SQL_HANDLE_ENV,hEnv
invoke MessageBox,hWnd,addr SetAttrFail,addr AppName,MB_OK+MB_ICONERROR
.endif
.ELSE
invoke MessageBox,hWnd,addr AllocEnvFail,addr AppName,MB_OK+MB_ICONERROR
.endif
ret
ODBCConnect endp


and here is SwithMenuState


SwithMenuState proc Flag:DWORD
.IF Flag==TRUE
invoke EnableMenuItem,hMenu,IDM_CONNECT,MF_GRAYED
invoke EnableMenuItem,hMenu,IDM_DISCONNECT,MF_ENABLED
.ELSE
invoke EnableMenuItem,hMenu,IDM_CONNECT,MF_ENABLED
invoke EnableMenuItem,hMenu,IDM_DISCONNECT,MF_GRAYED
.endif
ret
SwithMenuState endp

i can assemble it but if i try to build the error message appear:

MainWindow.obj : error LNK2001: unresolved external symbol _SwitchMenuState@4
MainWindow.exe : fatal error LNK1120: 1 unresolved externals

Make error(s) occured.
ERROR On Build: Version Number Was Not Increased.


Thanks in advanced

regards,
coredump:stupid:
Posted on 2003-11-14 19:01:03 by coredump
SwithMenuState proc Flag:DWORD
.IF Flag==TRUE
invoke EnableMenuItem,hMenu,IDM_CONNECT,MF_GRAYED
invoke EnableMenuItem,hMenu,IDM_DISCONNECT,MF_ENABLED
.ELSE
invoke EnableMenuItem,hMenu,IDM_CONNECT,MF_ENABLED
invoke EnableMenuItem,hMenu,IDM_DISCONNECT,MF_GRAYED
.endif
ret
SwithMenuState endp

^ spelling...should be SwitchMenuState

also move 'end start' to the end.
Posted on 2003-11-14 21:27:19 by Wayne
:grin: :grin: :grin: :grin: :grin:


:alright:

hi Wayne,

:grin: thank you! more power to all! :alright:





regards,
coredump
Posted on 2003-11-14 23:11:31 by coredump