ado - mssql - mysql

Moderator: Rathinagiri

Post Reply
skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

ado - mssql - mysql

Post by skonuk » Sat Sep 25, 2010 10:58 am

hmgversiyon 4 and mysql and / or ado - mssql connection When can we do?
I think there is currently only on the development of graphical user interface.

User avatar
Rathinagiri
Posts: 5161
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 127 times
Been thanked: 129 times
Contact:

Post by Rathinagiri » Sat Sep 25, 2010 11:19 am

As you have correctly said, HMG 4 is now concentrating on GUI via QT. Except for dbf field/browsing features, all other databases can be connected even now since it is based on mingw. If you have mysql/sqlite/mssql libraries to connect, I think even now we can connect as usual.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Roberto Lopez
HMG Founder
Posts: 3899
Joined: Wed Jul 30, 2008 6:43 pm
Has thanked: 13 times
Been thanked: 135 times

Post by Roberto Lopez » Sat Sep 25, 2010 11:44 am

rathinagiri wrote:As you have correctly said, HMG 4 is now concentrating on GUI via QT. Except for dbf field/browsing features, all other databases can be connected even now since it is based on mingw. If you have mysql/sqlite/mssql libraries to connect, I think even now we can connect as usual.
And... an area of QT that we do not explored yet, is the plugins (we do only for images).

QT includes redistributable plugins to handle sqlite and ODBC that could give us a grid with built in support for any back-end.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)

skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

Post by skonuk » Sat Sep 25, 2010 11:56 am

this sample, roberto's rdd sample.
and modified hbqt4


#include "../../include/hmg.ch"
Set Procedure To ../../source/hmg

REQUEST SDDODBC, SQLMIX

#define RDDI_CONNECT 1001

PROC main()

RDDSETDEFAULT( "SQLMIX" )
SET( 4, "yyyy-mm-dd" )
RDDINFO( RDDI_CONNECT, { "ODBC", "DBQ=" + "test.mdb;Driver={Microsoft Access Driver (*.mdb)}" } )
DBUSEAREA( .T.,, "select * from test", "test" )

INDEX ON FIELD->SALARY TO salary
DBGOTOP()

With Object oWindow := Window():New()
:Row := 10
:Col := 10
:Width := 400
:Height := 450
:Title := 'Nice OOP Demo!!!'
:Type := WND_MAIN
:OnInit := { || oWindow:Center() }

With Object oGrid := Grid():New()
:Row := 10
:Col := 10
:Width := 320
:Height := 300
:ColumnWidths := {150,60,70}
:ColumnHeaders := {'First','Last','Salary'}
:Rowsource := 'TEST'
:ColumnFields := {'First','Last','Salary'}
:CellNavigation := .T.

End With



End With
oWindow:Activate()


rETURN


this program not compiling (error code undefined reference to 'HB_FUN_SDDODBC' and 'HB_FUN_SQLMIX')

skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

Post by skonuk » Sun Oct 17, 2010 9:17 pm

- modify 1
#
# $Id: hbmk.hbm 15253 2010-08-01 12:32:44Z vszakats $
#

../../../harbour/contrib/hbqt/hbqtcore.hbc
../../../harbour/contrib/hbqt/hbqtgui.hbc
../../../harbour/contrib/hbqt/hbqtnetwork.hbc
sddodbc.hbc
rddsql.hbc

- modify 2
copy sddodbc.hbc and rddsql.hbc to this program directory

- and modify program



#ifdef __HBIDE__
#include "hmg.ch"
#else
#include "../../include/hmg.ch"
#endif

Set Procedure To ../../source/hmg

REQUEST SDDODBC, SQLMIX

#define RDDI_CONNECT 1001
#define RDDI_CONNECT 1001
#define RDDI_DISCONNECT 1002
#define RDDI_EXECUTE 1003
#define RDDI_ERROR 1004
#define RDDI_ERRORNO 1005
#define RDDI_NEWID 1006
#define RDDI_AFFECTEDROWS 1007
#define RDDI_QUERY 1008

Function Main
Local oWindow, oBrowse
RDDSETDEFAULT( "SQLMIX" )
RDDINFO( RDDI_CONNECT, { "ODBC", "SERVER=SK\SQLEXPRESS;DATABASE=TANGO;Driver={SQL Native Client};UID=sa;" } )
DBUSEAREA( .T.,, "select * from STOK_K ", "DEMO" )
Index on demo->STOK_K_ID to first
go top
With Object oWindow := Window():New()
:Row := 10
:Col := 10
:Width := 800
:Height := 480
:Title := 'Nice OOP Demo!!!'
:Type := WND_MAIN
:OnInit := { || oWindow:Center() }

With Object oBrowse := Browse():New()
:Row := 10
:Col := 10
:Width := 750
:Height := 450
:WorkArea := 'demo'
:OnDblClick := { || MsgInfo('Double Clicked!') }
End Width

End With

oWindow:Activate()



Return NIL

- this program connect to ms-sql server and browsing records :)

thanks
best regards
salim
bursa-turkey

huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Post by huangchenmin » Tue Mar 13, 2012 10:45 am

skonuk wrote:- modify 1
#
# $Id: hbmk.hbm 15253 2010-08-01 12:32:44Z vszakats $
REQUEST SDDODBC, SQLMIX
......
#define RDDI_CONNECT 1001
#define RDDI_CONNECT 1001
#define RDDI_DISCONNECT 1002
#define RDDI_EXECUTE 1003
#define RDDI_ERROR 1004
#define RDDI_ERRORNO 1005
#define RDDI_NEWID 1006
#define RDDI_AFFECTEDROWS 1007
#define RDDI_QUERY 1008
.......
bursa-turkey
Dear skonuk:
I read you artical about connecting to SQL server with HMG. Thanks to people like you and mol, I did connect to SQL server express 2005 successfully.
Meanwhile, I notice that you define RDD number such as 1002,1003 other than 1001. are they corresponding to specific SQL statement or other purposes?
Could you tell me more info about RDDINFO() ,or where I could I those information. Besides, do you know what else value RDDIFNO() will return other than zero? If do, what are they stand for?
Best Regrads
chen min

skonuk
Posts: 28
Joined: Fri Sep 17, 2010 7:37 pm
Location: turkey-bursa

Post by skonuk » Wed Apr 04, 2012 6:44 pm

Greetings,
not efficient for me with the sql connection rddinfo

The following is another example. The connection is established with hbodbc here.
A crucial part of the auto increment value which is important sahanında be taken after the insert is a great example I think.

odbc connection to MS SQL Server 2008 version of this is connected with success, inserts post-process percentage values ​​for auto increment column brought back with success.

I am interested in a very amateurish. better try to send the samples.

Good luck and good work


#include "simpleio.ch"

#include "sql.ch"

#xcommand GET ROW <nRow> INTO <cVar> => ;
<cVar> := Space( 128 ) ;;
SQLGetData( hStmt, <nRow>, SQL_CHAR, Len( <cVar> ), @<cVar> )

PROCEDURE Main()

LOCAL hEnv := 0
LOCAL hDbc := 0
LOCAL hStmt := 0
LOCAL cConstrin
LOCAL cConstrout := Space( 1024 )
LOCAL nRows := 0
LOCAL nid := 0


? "Version: " + hb_NumToHex( hb_odbcVer() )

cConstrin :="Driver={SQL Server Native Client 10.0};Server=SK\SQLEXP;Database=TANGO;Uid=SA;Pwd=;"


? PadC( "*** ODBC ACCESS TEST ***", 80 )
?
? "Allocating environment... "
SQLAllocEnv( @hEnv )
? "Allocating connection... "
SQLAllocConnect( hEnv, @hDbc )
? "Connecting to driver " + cConstrin + "... "
SQLDriverConnect( hDbc, cConstrin, @cConstrout )
? "Allocating statement... "
SQLAllocStmt( hDbc, @hStmt )
?


sqlexecdirect( hstmt, "INSERT INTO test (kolon1,kolon2,kolon3,kolon4) VALUES ('EqqS','ddd','eee','eee') ")
?
sqlexecdirect( hstmt, "SELECT * FROM TEST where a1=@@identity")


DO WHILE SQLFetch( hStmt ) == 0
nRows++

GET ROW 5 INTO nid
* GET ROW 2 INTO cFunc
* GET ROW 3 INTO cState
* GET ROW 4 INTO cComm
* GET ROW 5 INTO nid
? nid
* ? cCode, PadR( cFunc, 20 ), cState, cComm, nid
ENDDO

? "------------------------------------------------------------------------------"
? Str( nRows, 4 ), " row(s) affected."

SQLFreeStmt( hStmt, SQL_DROP )
SQLDisConnect( hDbc )
SQLFreeConnect( hDbc )
SQLFreeEnv( hEnv )

RETURN

huangchenmin
Posts: 157
Joined: Mon Jun 07, 2010 2:24 am

Post by huangchenmin » Tue Apr 24, 2012 12:55 am

skonuk wrote:Greetings,
not efficient for me with the sql connection rddinfo

The following is another example. The connection is established with hbodbc here.
......
RETURN
Dear skonuk:
Very thanks for replying to me. To be honest, it is really tough for me to understand. but I will keep trying.
Thank you again.
Best Regards
chen min

Post Reply