Question about SQL

Question about SQL

Postby driessen » Tue Nov 20, 2007 3:10 pm

Hello,

I am thinking about transferring my DBF-files in my FWH-application to a SQL-database.

Until now, I have no experience at all with SQL.

What do I need to do ?

Or where can I find a good manual to do the transfer ?

Thank you in advance.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Rick Lipkin » Tue Nov 20, 2007 5:42 pm

Driessen

ADO is the best choice for me .. there is the 'free' ado rdd available on this forum or you can do it the way I do and code everything manually with recordsets.

I wrote a thread on the subject with samples:

http://fivetechsoft.com/forums/viewtopi ... &highlight

If I can be of any help just drop me a message.

Rick Lipkin
SC Dept of Health, USA
lipkinrm29063@yahoo.com
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby driessen » Tue Nov 20, 2007 7:06 pm

Rick,

Thanks a lot for your answer.

I'll read your topic very carrefully. If necessary I'll send you a mail for some more help.

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Rick Lipkin » Wed Nov 21, 2007 12:20 am

Michel

Here is some specific code and listbox for MS Sql server .. note the connection string .. :

// public defined in Main.prg:

xPROVIDER := "SQLOLEDB"
xSOURCE := "MSSQL01"
xCATALOG := "PCAS"
xUSERID := "pcasuser"
xPASSWORD := "pcas"



// grpbrow.prg
//
#INCLUDE "FIVEWIN.CH"
STATIC oBROW,oGRP
STATIC lOK
//----------------------------
FUNCTION _GRPbrow( oWndMDI )
LOCAL SAYING, oRs,oErr, cSQL, cTITLE
lOK := .F.
IF xSUPER = 'Y' .or. xADMIN = 'Y'
ELSE
SAYING := "SORRY ... Supervisor or Admin Rights only"
MsgAlert( SAYING )
_CleanUp()
RETURN(.F.)
ENDIF

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType := 1 // opendkeyset
oRs:CursorLocation := 3 // local cache
oRs:LockType := 3 // lockoportunistic
IF xADMIN = 'Y'
cSQL := "SELECT * FROM GROUPS ORDER BY PROGID,CODE"
cTITLE := "Group Records Browse for ALL"
ELSE
cSQL := "SELECT * FROM GROUPS where progid = '"+xPROGID+"' ORDER BY CODE"
cTITLE := "Group Records Browse for Progid "+xPROGID
ENDIF
TRY
oRs:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
MsgInfo( "Error in Opening GROUPS table" )
_CleanUp()
RETURN(.F.)
END TRY
IF oRs:EOF
oRs:Close()
SAYING := "Could not find any matching records for "+cSQL
MsgInfo( SAYING )
_CleanUp()
RETURN(.F.)
ENDIF
oRs:MoveFirst()
DEFINE WINDOW oGRP ;
FROM 2,2 to 30,70 ;
of oWndMDI ;
TITLE cTITLE ;
MENU BuildMenu( oRs ) ;
NOMINIMIZE ;
NOZOOM ;
MDICHILD
@ 0, 0 LISTBOX oBrow FIELDS ;
oRs:Fields("CODE"):Value, ;
oRs:Fields("DESC"):Value, ;
oRs:Fields("progid"):Value ;
SIZES 80,250,80 ;
HEADERS "Code", ;
"Description", ;
"ProgID" ;
of oGRP ;
ON DBLCLICK( _GrpView( "V", oRs )) ;
UPDATE
oBrow:bLogicLen := { || oRs:RecordCount }
oBrow:bGoTop := { || oRs:MoveFirst() }
oBrow:bGoBottom := { || oRs:MoveLast() }
oBrow:bSkip := { | nSkip | Skipper( oRs, nSkip ) }
oBrow:cAlias := "ARRAY"
oGrp:oClient := oBROW
oGrp:SetControl( oBrow )

ACTIVATE WINDOW oGRP ;
VALID ( IIF( !lOK, GrpCLose( .T. , oRs ), .F. ))
RETURN( NIL )
//-------------------------------
Static Func _Cleanup()
oBROW := NIL
oGRP := NIL
RETURN(.T.)
//------------------//
static FUNCTION BuildMenu( oRs )
LOCAL oMenu1
MENU oMenu1
MENUITEM "&Add ..." ;
ACTION ( _GRPVIEW( "A", oRs ), ;
oBROW:Refresh() ) ;
MESSAGE "Add a new record"
MENUITEM "&Edit ..." ;
ACTION ( _GRPVIEW( "E", oRs ), ;
oBROW:ReFresh() ) ;
MESSAGE "Edit this record"
MENUITEM "&Delete ..." ;
ACTION GRPDEL( oRs) ;
MESSAGE "Delete this record"
MENUITEM "&View ..." ;
ACTION _GRPVIEW( "V", oRs ) ;
MESSAGE "View this record"
MENUITEM "&Quit" ;
ACTION oGRP:END()
ENDMENU
RETURN( oMenu1 )
//------------------------
Static FUNCTION GRPCLOSE(lCLEAN, oRs )
IF lCLEAN = .T.
lOK := .T.
oBROW:cALIAS := nil
oRs:Close()
_CleanUp()
ENDIF
RETURN(lOK)
//--------------------
Static FUNCTION GRPDEL( oRs )
LOCAL SAYING
IF xSUPER = 'Y' .or. xADMIN = 'Y'
ELSE
SAYING := "Sorry ... Supervisor or Admin Rights Only"
MsgAlert( SAYING )
RETURN(NIL)
ENDIF
IF oRs:EOF
SAYING := "Sorry ... Before you can Delete a "
SAYING += "record, you have to Add one first"
MsgAlert( SAYING )
RETURN(NIL)
ENDIF
IF MsgYesNo( "Are you SURE you want to DELETE this?" )
oRs:Delete()
oRs:MoveNext()
IF oRs:eof .and. .not. oRs:bof
oRs:MoveFirst()
ENDIF
ENDIF

oBROW:Refresh(.T.)
SysReFresh()
RETURN(NIL)
//-------------------------------
STATIC FUNCTION SKIPPER( oRsx, nSkip )
LOCAL nRec := oRsx:AbsolutePosition
oRsx:Move( nSkip )
IF oRsx:EOF; oRsx:MoveLast(); ENDIF
IF oRsx:BOF; oRsx:MoveFirst(); ENDIF
RETURN( oRsx:AbsolutePosition - nRec )
// end GRPBROW.PRG
User avatar
Rick Lipkin
 
Posts: 2642
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Enrico Maria Giordano » Wed Nov 21, 2007 8:55 am

Rick, do you have a connection string for MySQL remote?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8408
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Nov 21, 2007 9:06 am

Enrico,

There is one included in the ADORDD samples :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Wed Nov 21, 2007 9:23 am

The following sample stops with DISP_E_UNKNOWNNAME:

Code: Select all  Expand view
FUNCTION MAIN()

    LOCAL oRs := CREATEOBJECT( "ADODB.Recordset" )

    oRs:Open( "SELECT * FROM Table", "DRIVER={MySQL ODBC 3.51 Driver};server=xxx.xxx.xxx.xxx;database=dbname;uid=username;pwd=password", 0, 3 )

    oRS:Close()

    RETURN NIL


Do I have to install something MySQL related on the client?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8408
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Nov 21, 2007 9:26 am

Enrico,

> Do I have to install something MySQL related on the client?

Yes, you have to install the MySQL client software
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Wed Nov 21, 2007 9:53 am

Do you have the link at hand? :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8408
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Nov 21, 2007 11:58 am

Enrico,

No, sorry :-(

As far as I remember you can download it from the MySQL website.

Its a long time since we tested it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Enrico Maria Giordano » Wed Nov 21, 2007 4:28 pm

Already found, thank you.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8408
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Wed Nov 21, 2007 5:15 pm

Enrico,

Would you mind to post here the download url ? Thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Postby Antonio Linares » Wed Nov 21, 2007 7:01 pm

Enrico,

Thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby ShumingWang » Thu Nov 22, 2007 2:38 am

Use harbour\contrib\Tmysql.prg ,without any windows setting ,direct TCP/IP using, like Xbase.
t1:=oserver:query("select * from table1 ")
t1:gotop()
t1:skip(1)
t1:fieldname1:="aaaa"
t1:save()
t1:delete()
t1:end()
...

Our modified tmysql.prg:
http://www.xtech.com.cn/down/tmysql.prg
http://www.xtech.com.cn/down/sample1.prg
http://www.xtech.com.cn/down/sample2.prg

Regards!
Shuming Wang
ShumingWang
 
Posts: 460
Joined: Sun Oct 30, 2005 6:37 am
Location: Guangzhou(Canton),China

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 126 guests