FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse-TMySql sample?
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
xBrowse-TMySql sample?
Posted: Mon Apr 02, 2012 02:33 AM

Greetings to all.
Can any of you show me an example tmysql xbrowse in which the xbrowse be refreshed after a consultation?

Let me explain: When I use oQuery: locate (), achieving the goal, but is too slow. If I use oQuery: Seek (), the key value is found, but the xBrowse not select the line that corresponds. Even moving the cursor.

Appreciate very much this small example TMySql and xBrowse.

thanks

:roll:

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: xBrowse-TMySql sample?
Posted: Mon Apr 02, 2012 04:06 AM

Maybe an oBrw:refresh() might work??

Thank you

Harvey
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: xBrowse-TMySql sample?
Posted: Mon Apr 02, 2012 11:44 AM

obrow:=bseek:={|v|odb2:SEEK(v,,{oquery:itemid+oquery:id2})}

tmysql query class
METHOD Seek(Value,lSoftSeek,cFieldNames,llast)
METHOD Seek( xValue,lSoftSeek,cFieldNames,llast) CLASS TMySQLQuery
local nstart,nend,nretry:=0,Xvalue0:=Xvalue,ctype:=VALTYPE(xValue)

default lSoftSeek to .t.
DEFAULT llast TO .f.

if ctype=="C"
if len(xValue)<LEN(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))
xValue:=PADR(xValue,len(cvaltochar(if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)))," ")
end
xValue:=UPPER(xValue)
xValue0:=UPPER(xValue0)
end

::lFound := .f.
::GoTop()
if RIGHT(UPPER(RIGHT(::cquery,8)),4)=="DESC"
if if(VALTYPE(cfieldnames)=="B",EVAL(cfieldnames),&cFieldNames)<xValue
if !lSoftseek
::GoBottom()
end

        return  ::lFound                                
    end

    if  valtype(xValue)==&quot;C&quot;
        ::GoBottom()
        if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames)),len(Xvalue0))==Xvalue0
             ::lfound:=.t.
             return ::lfound
         else
             ::GoTop()                    
        end
    end

   while .t.                                            
     nStart:=1                                          
     nEnd:=::lastrec()                                  
     while nEnd-nStart&gt;1                                
         ::GoTo( nStart+int( (nEnd-nStart)/2))  
       if ctype&lt;&gt;&quot;C&quot;          
         Do Case                                        
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&lt;xValue                   
                  nend := ::nCurRow                     
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue                  
                ::lFound := .t.                         
                  exit                                  
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&gt;xValue                   
                  nStart := ::nCurRow                   
         endcase 
         else
            Do Case                                        
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&lt;xValue                   
                  nend := ::nCurRow                     
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))==xValue                  
                ::lFound := .t.                         
                  exit                                  
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&gt;xValue                   
                  nStart := ::nCurRow                   
         endcase 
        endif                                      
     enddo

    if ::lFound; exit; end                             
     ::GoTo(nStart)                                     
    if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue ; ::lfound :=.t.; exit; end
    if  ctype==&quot;C&quot;
       if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
    end   
     ::GoTo(nEnd)                                       
    if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue ; ::lfound :=.t.; exit; end
    if  ctype==&quot;C&quot;
       if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
    end                                                       
     exit                                               
   enddo

     if !::lFound.and.!lSoftseek; ::GoBottom(); end     
     if ::lfound.and.llast                              
         while nEnd-nStart&gt;1                            
             ::GoTo( nStart+int( (nEnd-nStart)/2)) 
             if ctype&lt;&gt;&quot;C&quot;    
                if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&lt;xValue                    
                 nend := ::nCurRow                      
                else                                      
                 // if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames))==xValue                
                 nStart := ::nCurRow                    
                end       
             else
                 if  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&lt;xValue                    
                 nend := ::nCurRow                      
                else                                      
                 // if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames))==xValue                
                 nStart := ::nCurRow                    
                end    
             endif                                 
         enddo                                          
         ::GoTo(nEnd)   
         if ctype&lt;&gt;&quot;C&quot;                                
            if if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&lt;xValue; ::GoTo(nStart); end    
           else
            if if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&lt;xValue; ::GoTo(nStart); end    
          endif   
     end

else

    if  ctype==&quot;C&quot;
        if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(cvaltochar(EVAL(cfieldnames))),UPPER(cvaltochar(&amp;cFieldNames))),len(Xvalue0))==Xvalue0
              ::lfound:=.t.
              return  ::lFound
        end      
    end

    if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&gt;xValue                            
        if !lSoftseek                                   
           ::GoBottom()                                 
        end                                           
        return  ::lFound                                
    end



   while .t.                                            
     nStart:=1                                          
     nEnd:=::lastrec()                                  
     while nEnd-nStart&gt;1                                
         ::GoTo( nStart+int( (nEnd-nStart)/2))   
       if ctype&lt;&gt;&quot;C&quot;        
         Do Case                                        
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&gt;xValue                   
                  nend := ::nCurRow                     
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue                  
                ::lFound := .t.                         
                  exit                                  
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&lt;xValue                   
                  nStart := ::nCurRow                   
         endcase 
          else
            Do Case                                        
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&gt;xValue                   
                  nend := ::nCurRow                     
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))==xValue                  
                ::lFound := .t.                         
                  exit                                  
            case  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&lt;xValue                   
                  nStart := ::nCurRow                   
         endcase 
       endif                                          
     enddo

    if ::lFound; exit; end                             
     ::GoTo(nStart)                                     
    if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue ; ::lfound :=.t.; exit; end
    if  ctype==&quot;C&quot;
        if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
    end

     ::GoTo(nEnd)                                       
    if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue ; ::lfound :=.t.; exit; end
    if  ctype==&quot;C&quot;
       if left(if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames)),len(Xvalue0))==Xvalue0; ::lfound:=.t.; exit; end
    end                                                     
     exit                                               
   enddo

     if !::lFound.and.!lSoftseek; ::GoBottom(); end     
     if ::lfound.and.llast                              
         while nEnd-nStart&gt;1                            
             ::GoTo( nStart+int( (nEnd-nStart)/2))     
             if ctype&lt;&gt;&quot;C&quot; 
                 if  if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&gt;xValue                    
                    nend := ::nCurRow                      
                 else                                      
                  // if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue                
                    nStart := ::nCurRow                    
                 end 
              else
                 if  if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&gt;xValue                    
                    nend := ::nCurRow                      
                 else                                      
                  // if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)==xValue                
                    nStart := ::nCurRow                    
                 end 
             endif                                           
         enddo                                          
         ::GoTo(nEnd)       
         if ctype&lt;&gt;&quot;C&quot;                            
            if if(VALTYPE(cfieldnames)==&quot;B&quot;,EVAL(cfieldnames),&amp;cFieldNames)&gt;xValue; ::GoTo(nStart); end    
         else
            if if(VALTYPE(cfieldnames)==&quot;B&quot;,UPPER(EVAL(cfieldnames)),UPPER(&amp;cFieldNames))&gt;xValue; ::GoTo(nStart); end

         end
     end

end

Return ::lFound

Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: xBrowse-TMySql sample?
Posted: Mon Apr 02, 2012 12:06 PM

Hag, thanks for your reply. I did it but not worked:
oQuery:Refresh()
oBrw:Refresh()

Shuming, I will try your modifications.
Thank you very much.

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 474
Joined: Sun Oct 30, 2005 06:37 AM
Re: xBrowse-TMySql sample?
Posted: Tue Apr 03, 2012 02:30 AM

obrow:=bseek:={|v|odb2:SEEK(v,,{oquery:itemid+oquery:id2})}

Should be
obrow:bseek:={|v|oquery:SEEK(v,,{||oquery:itemid})}

Shuming Wang

http://www.xtech2.top
Mobile:(86)13802729058
Email:100200651@qq.com
QQ:100200651
Weixin: qq100200651
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: xBrowse-TMySql sample?
Posted: Wed Apr 04, 2012 08:24 PM

Hello Shuming.
Thank you for your interest in helping. I tried to create tmysql.lib, but I have problems. This is the first time I try to do it.

In compiling this error is show:

MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
C: \ XHARBOUR_1.21_6714_BCC582 \ BIN \ harbour.exe mysqlrdd.prg-q0-w-ES2-gc0-n-iC: \ XHARBOUR_1.21_6714_BCC582 \ include, C: \ XHARBOUR_1.21_6714_BCC582 \ TMYSQL \ MYSQL_SERVER_51 \ INCLUDE-o. \ OBJ \ mysqlrdd.c
C: \ BCC582 \ BIN \ bcc32-c-O2-IC: \ XHARBOUR_1.21_6714_BCC582 \ include, C: \ XHARBOUR_1.21_6714_BCC582 \ TMYSQL \ MYSQL_SERVER_51 \ INCLUDE-DHB_OS_WIN_32_USED-o. \ OBJ \ mysqlrdd.obj. \ OBJ \ mysqlrdd . c
Borland C + + 5.82 for Win32 Copyright (c) 1993, 2005 Borland
. \ OBJ \ mysqlrdd.c:
C: \ BCC582 \ BIN \ TLIB C: \ XHARBOUR_1.21_6714_BCC582 \ LIB \ mysql.lib - +. \ OBJ \ mysqlrdd.obj,,
TLIB 4.5 Copyright (c) 1987, 1998 Borland International

C: \ XHARBOUR_1.21_6714_BCC582 \ BIN \ harbour.exe tmysql.prg-q0-w-ES2-gc0-n-iC: \ XHARBOUR_1.21_6714_BCC582 \ include, C: \ XHARBOUR_1.21_6714_BCC582 \ TMYSQL \ MYSQL_SERVER_51 \ INCLUDE-o. \ OBJ \ tmysql.c
tmysql.prg (226) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (663) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (763) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (893) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (1701) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (2176) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
tmysql.prg (2261) Warning W0001 Ambiguous reference: 'MYSQL_NEWDECIMAL_TYPE'
0 error
No code generated
** Error 1 ** deleting. \ OBJ \ tmysql.c

Later I modify Mysql.ch and compile without problems but when trying to compile the system, shows these errors:

Compiled and Linking: [D: \ FAPSOFT \ NEWCONT32_MYSQL \ Wcont32.Exe]
Running # 1
Executed at: 14:09:36
================================================== ==========
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6717)
Copyright 1999-2010, http://www.xharbour.org http://www.harbour-project.org/
Compiling 'D: \ FAPSOFT \ NEWCONT32_MYSQL \ wcont32.prg' and Generating preprocessed output to 'D: \ FAPSOFT \ NEWCONT32_MYSQL \ wcont32.ppo' ...
Lines 1090, Functions / Procedures 192
Generating C source output to 'D: \ FAPSOFT \ NEWCONT32_MYSQL \ wcont32.hrb' ...
Borland C + + 5.82 for Win32 Copyright (c) 1993, 2005 Borland
D: \ FAPSOFT \ NEWCONT32_MYSQL \ wcont32.hrb:
Turbo Incremental Link 5.69 Copyright (c) 1997-2005 Borland
Error: Unresolved external 'SQLAllocEnv' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLAllocConnect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLExecDirect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLDriverConnect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLConnect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLAllocStmt' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLDescribeCol' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLError' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLPrepare' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLFreeStmt' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLDisconnect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLFreeConnect' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLFreeEnv' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLNumResultCols' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLFetch' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetInfo' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSetConnectOption' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSetStmtOption' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetConnectOption' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetStmtOption' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSetCursorName' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetCursorName' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLRowCount' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLCancel' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLTransact' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSetParam' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLExecute' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLParamData' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLPutData' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLExtendedFetch' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSetPos' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLPrimaryKeys' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetDiagRec' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLStatistics' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLColumns' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLSpecialColumns' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLTables' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external 'SQLGetData' referenced from C: \ FWH1006 \ LIB \ FIVEHC.LIB | ODBC32X
Error: Unresolved external '_HB_FUN_SQLVERSION' referenced from C: \ XHARBOUR_1.21_6714_BCC582 \ LIB \ MYSQL.LIB | tmysql
End of process.
MAKE Version 5.2 Copyright (c) 1987, 2000 Borland
** Error 2 ** deleting D: \ FAPSOFT \ NEWCONT32_MYSQL \ Wcont32.exe
There were errors trying to build the application
================================================== ==========
Verce v4.3 -> View Results compile and link v4.3
Juan Carlos Salinas Ojeda

jcso@hotmail.com, jcso@esm.com.mx
Minatitlan, Veracruz. MEXICO
And just Veracruz is beautiful!
FiveWin for Harbour!

I'm lost ...!
Thank you for your good intentions.
Greetings.

Francisco

Francisco J. Alegría P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql

Continue the discussion