#include "fivewin.ch"
#include "adodef.ch"
static oCn
//----------------------------------------------------------------------------//
function Main()
local oRs, cSql, aStruct
local cTable := "namesutf8"
FW_SetUnicode( .t. )
? "Connecting to MySql Server"
oCn := FW_OpenAdoConnection( "MYSQL,localhost,fwh,root,India@1947", .t. )
if oCn == nil
? MsgStop( "Connect Fail" )
return nil
endif
if .not. FW_AdoTableExists( cTable, oCn ) .or. ;
MsgYesNo( "Recreate table " + cTable )
TRY
oCn:Execute( "DROP TABLE " + cTable )
CATCH
END
aStruct := { ;
{ "code", 'C', 2, 0 }, ;
{ "name", "VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" } }
FWAdoCreateTable( cTable, aStruct, oCn )
endif
oRs := FW_OpenRecordSet( oCn, cTable )
XBROWSER oRs FASTEDIT TITLE FWVERSION
oRs:Close()
oCn:Close()
return nil
//----------------------------------------------------------------------------//
#include 'fivewin.ch'
#include "xbrowse.ch"
Static oServer
function main
FW_SetUnicode( .T. )
oServer:= TMYSQLSERVER():new( 'localhost', 'root', 'nimda', 3306)
IF oserver:lError
MSGALERT( "There was error connecting will check if there is connection to the server or user / password is incorrected")
Return Nil
Endif
oServer:selectdb("easyfo")
ShowxBr( oServer, 'namesutf8' )
return nil
*-----------------------*
Procedure ShowxBr( oServer, cTable )
local oqry, oDlg, oBrw
oqry:=oServer:Query( "SELECT * FROM "+lower(cTable) )
IF oqry:lError
? "It could not open the database "
Return
endif
oqry:end()
XBROWSER oqry FASTEDIT TITLE FWVERSION
return nil
cnavarro wrote:I not use TMySql, or TDolphin, but
You are tested with HB_SETCODEPAGE( "UTF8" ) ?
#include "FiveWin.Ch"
#include "tdolphin.ch"
static cpw := "xxxxxxx"
//----------------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont
local oQry
FW_SetUnicode( .T. )
db()
oQry := TDolphinQry():New( "SELECT * FROM namesutf8", db() )
DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 500,300 PIXEL TITLE FWVERSION + " : TDolphin" ;
FONT oFont
@ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
DATASOURCE oQry ;
COLUMNS "code", "name" ;
CELL LINES NOBORDER AUTOSORT FASTEDIT
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
//
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
db():End()
return (0)
//----------------------------------------------------------------------------//
function db()
static oCn
if oCn == nil
CONNECT oCn ;
HOST "localhost" USER "root" PASSWORD cpw DATABASE "fwh"
endif
return oCn
//----------------------------------------------------------------------------//
#include 'fivewin.ch'
#include "xbrowse.ch"
#include 'Tdolphin.ch'
Static oServer, oFont
function main
HB_SETCODEPAGE( "UTF8" )
FW_SetUnicode( .T. )
oServer:= ConnectMySql( 'localhost', 'root', 'nimda', 3306, 0, 'easyfo')
IF oserver:lError
MSGALERT( "There was error connecting will check if there is connection to the server or user / password is incorrected")
Return Nil
Endif
ShowxBr( oServer, 'namesutf8' )
return nil
*-----------------------*
Procedure ShowxBr( oServer, cTable )
local oqry, oDlg, oBrw, oErr
TRY
oqry:=oServer:Query( "SELECT * FROM "+lower(cTable) )
CATCH oErr
? "It could not open the database "
Return
END TRY
DEFINE FONT oFont NAME "Segoe UI" SIZE 0,-16
DEFINE DIALOG oDlg SIZE 500, 300 PIXEL TITLE FWVERSION FONT oFont
@ 0, 0 XBROWSE oBrw SIZE -10, -10 PIXEL OF oDlg ;
DATASOURCE oqry ;
COLUMNS "Code", "Name" ;
FASTEDIT NOBORDER LINES CELL AUTOSORT
oBrw:CreateFromCode()
// oDlg:oClient := oBrw
ACTIVATE DIALOG oDlg CENTER
// XBROWSER oqry FASTEDIT TITLE FWVERSION
oqry:end()
return nil
*-------------------------------------------------------------------------*
Function ConnectMySql( cServer, cUser, cPassword, nPort, nFlags, cDBName )
local oSvr, oErr
TRY
CONNECT oSvr HOST cServer ;
USER cUser ;
PASSWORD cPassword ;
PORT nPort ;
FLAGS nFlags;
DATABASE cDBName
CATCH oErr
MsgStop( hb_dumpvar( oErr ) )
RETURN NIL
END
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 98 guests