Hi ASM coders,

Good Day!

I have some question about odbc programming in asm I want to create
a small program that will search in sample.mdb database.I already
connected to database the problem is I have no idea how to put the
SQL statement and the result of the search into edit box.The SQL statement
"select * from table where books=? and verse=?"; where books is the value
of combobox and the verse is the value of editbox for example
"select * from table where books="Geneses" and verse="1:1"".

I attached my code.Thank you in advanced.
Posted on 2003-11-17 20:30:37 by coredump
I don't know anything about database programming but have you looked at iczelion's ODBC tutorials?.
Posted on 2003-11-17 20:49:59 by Odyssey
hi Odyssey,

yeah i already read the iczelion's ODBC tutorials. can you helpme to
put the value of combobox in to a variable? like for example
if I click the button of READ it will copy the value of combobox
into a variable then i will put a SQL statement like
"select * from table where books=" & strcombobox & "and verse=" & streditbox &"




regards,
coredump
Posted on 2003-11-17 21:07:07 by coredump
coredump,

You can use the GetWindowText function to get the text from the combo box. I tried it to make sure it worked.

 


.IF dx==BN_CLICKED
.IF ax==Button01ID
invoke QueryStrings,hWnd
invoke GetWindowText,hWnd,ADDR SearchName,25
invoke GetWindowText, hCombobox01, addr buf, 100

Posted on 2003-11-17 22:08:12 by Odyssey
Hi Odyssey,

do you know how to Fill data in editbox coz i want to Fill the data result
of my query in SQL to the editbox, in iczelion's ODBC tutorial the code is:
;-- -------------------------------------------
FillData proc
LOCAL lvi:LV_ITEM
LOCAL row:DWORD

invoke SQLBindCol, hStmt,1,SQL_C_CHAR, addr TheName, sizeof TheName,addr NameLength
invoke SQLBindCol, hStmt,2,SQL_C_CHAR, addr TheSurname, sizeof TheSurname,addr SurnameLength
invoke SQLBindCol, hStmt,3,SQL_C_CHAR, addr TelNo, sizeof TelNo,addr TelNoLength
mov row,0
.while TRUE
mov byte ptr ds:,0
mov byte ptr ds:,0
mov byte ptr ds:,0
invoke SQLFetch, hStmt
.if ax==SQL_SUCCESS || ax==SQL_SUCCESS_WITH_INFO
mov lvi.imask,LVIF_TEXT+LVIF_PARAM
push row
pop lvi.iItem
mov lvi.iSubItem,0
mov lvi.pszText, offset TheName
push row
pop lvi.lParam
invoke SendMessage,hList, LVM_INSERTITEM,0, addr lvi
mov lvi.imask,LVIF_TEXT
inc lvi.iSubItem
mov lvi.pszText,offset TheSurname
invoke SendMessage,hList,LVM_SETITEM, 0,addr lvi
inc lvi.iSubItem
mov lvi.pszText,offset TelNo
invoke SendMessage,hList,LVM_SETITEM, 0,addr lvi
inc row
.else
.break
.endif
.endw
ret
FillData endp
;------------------------------------

but my problem is i want to put the result in editbox not in the listbox.
Thanks in advanced.


regards,
coredump
Posted on 2003-11-18 00:40:15 by coredump
Use SetWindowText if I am not wrong.
Posted on 2003-11-18 00:58:00 by roticv
hi roticv,


Thank, but how can i retrieve the value of my query?
if SetWindowText(
HWND hWnd, // handle of window or control
LPCTSTR lpString // address of string
);

where can i find my address of string which is the value is
my query result?


regards,
coredump
Posted on 2003-11-18 01:40:10 by coredump
That would be the lpString parameter I think if I understand what you're asking.
Posted on 2003-11-18 06:54:43 by Odyssey
hi Odyssey,

Good Day!

yes lpString, can you help me how to put the value of my SQL query result
to the editbox? or how to fill data in editbox with my SQL query result in
database? for example the SQL statement is:
"select * table where text like '*adam*'". so all result will be fillup in editbox.
can you help me?

Thanks in advanced



regards,
coredump
Posted on 2003-11-18 19:17:39 by coredump
"select * from table where books=" & strcombobox & "and verse=" & streditbox &" is your query string right? Looks like vb code :grin:. You can't use the & operator to concatenate strings with masm but you can use szMultiCat function in the masm32 library. Then use the SetWindowText function to put the string in an editbox.
Posted on 2003-11-18 19:50:19 by Odyssey
hi Odyssey,

yes that is a VB code.Thanks! I will try szMultiCat.
do you know some sample program in ASM ODBC?



regards,
coredump
Posted on 2003-11-18 19:57:59 by coredump
The only ODBC code with asm I know of is that from iczelion's tutorials.
Posted on 2003-11-18 20:01:20 by Odyssey
hi Odyssey,

Thanks.




regards,
coredump
Posted on 2003-11-18 20:49:22 by coredump
Don't mention it :) but I thought you read the ODBC tutorials before.
Posted on 2003-11-18 20:54:53 by Odyssey
yeah i already read the ODBC tutorials. but my program still not running..

can you check my coding if there is something wrong?


here is the code:
Posted on 2003-11-18 21:22:31 by coredump
What is hSmt variable for? Is it a handle to something or is it supposed to be a string?
It's declared as a single dword so I think it's a handle but it was passed to a function that was expecting a string so I am confused.
Posted on 2003-11-18 21:49:50 by Odyssey
coredump,

a few things to look at (I'm looking at your first download),

SQLStatement db "select * from AngBiblia ",0
WhereStatement db "where verse = ? and books = ?",0

you need a space in there or you end up with
select * from AngBibliawhere verse = ? and books = ?

Also, you need to bind 2 parameters.

Get the 2 variables you need:


.IF ax==Button01ID
invoke GetWindowText,hCombobox01,ADDR SearchName,25
invoke GetWindowText,hEdit02,ADDR SearchVerse,25

Then bind the 2 :


QueryStrings proc hWnd:DWORD
invoke SQLAllocHandle,SQL_HANDLE_STMT,hConn,addr hStmt
.if ax==SQL_SUCCESS || SQL_SUCCESS_WITH_INFO
invoke lstrcpy,addr Conn,addr SQLStatement
invoke lstrcat,addr Conn,addr WhereStatement
invoke SQLBindParameter,hStmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,25,0,addr SearchVerse,25,addr StrLen
invoke SQLBindParameter,hStmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,25,0,addr SearchName,25,addr StrLen
invoke SQLPrepare,hStmt,addr Conn,sizeof Conn

Also, I would move your call to QueryStrings to your ODBC Connect proc. You only need to call QueryStrings once
to bind the parameters to the variables. You can the just change the variables and do the SQLExec.
Posted on 2003-11-19 12:17:02 by Wayne
hi Wayne,

Thank you!i got it but how to put or to fill up the result in hEdit01?
in Iczelion's ODBC tutorial there is a FillData proc to fill up the
result in listbox but i want it in my hEdit01 can you help me?

Thank you to all of you.


regards,
coredump
Posted on 2003-11-19 21:13:24 by coredump
You can try

invoke SetWindowText , hEdit01, theStringYouWantInhEdit01
Posted on 2003-11-19 21:19:32 by Odyssey
Hi Odyssey,

Thank you!
but my problem is;
invoke SetWindowText , hEdit01, ??? ;where is my query result or the string?

in the example of Iczelion he use LVM_INSERTITEM and LV_ITEM i think this where
the result query stored?

invoke SendMessage,hList, LVM_INSERTITEM,0, addr lvi

what is the syntax in editbox?
Posted on 2003-11-19 22:11:26 by coredump