ADORDD
Moderator: Rathinagiri
- danielmaximiliano
- Posts: 2612
- Joined: Fri Apr 09, 2010 4:53 pm
- Location: Argentina
- Contact:
Re: ADORDD
In C:\Harbour\extras\rddado , adordd.prg, STATIC FUNCTION ADO_OPEN( nWA, aOpenInfo ), line 292
connection with .xls files is generated, a syntax addition would be needed to see if it is likely to use this extra harbour library
Code: Select all
CASE Lower( Right( aOpenInfo[ UR_OI_NAME ], 4 ) ) == ".xls"
aWAData[ WA_CONNECTION ]:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + aOpenInfo[ UR_OI_NAME ] + ";Extended Properties='Excel 8.0;HDR=YES';Persist Security Info=False" )
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*
Saludos / Regards
DaNiElMaXiMiLiAnO
Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
hi,
i saw that file but before use it i want to ask if it is still valid ... not like PGRDD
now Demo use existing Data but i try to create a XLSx and write Data from DBF using ADO.
i try CREATE TABLE but this seem not to work with Excel
i saw that file but before use it i want to ask if it is still valid ... not like PGRDD
now Demo use existing Data but i try to create a XLSx and write Data from DBF using ADO.
i try CREATE TABLE but this seem not to work with Excel
have fun
Jimmy
Jimmy
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
hi,
i found out i need to create a Table in Catalog before fill it.
than i try use INSERT INTO and i got a *.XLSx which Excel can open
but i can´t open same *.XLSx with ADO again ...
so something still not working
i found out i need to create a Table in Catalog before fill it.
Code: Select all
oConnect := CreateObject( "ADODB.Connection" )
oCatalog := CreateObject( "ADOX.Catalog" )
oTable := CreateObject( "ADOX.Table" )
FOR ii := 1 TO iMax
cField := aStructure[ ii ] [ DBS_NAME ]
cType := aStructure[ ii ] [ DBS_TYPE ]
oColumn := CreateObject( "ADOX.Column")
oColumn:Name := cField
DO CASE
CASE cType = "C" ; oColumn:Type := adVarWChar
CASE cType = "M" ; oColumn:Type := adLongVarWChar
CASE cType = "N" ; oColumn:Type := adDouble
CASE cType = "D" ; oColumn:Type := adDate
CASE cType = "L" ; oColumn:Type := adBoolean
ENDCASE
oTable:Columns:Append(oColumn)
NEXT
oCatalog:Tables:Append(oTable)
have fun
Jimmy
Jimmy
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
hi,
i have try ADO Recordset instead of INSERT INTO
XLSx is create and Excel can open it ... but same when i try to read it with ADO
---
while both seems to work i guess Problem is before ... how to create Table ... hm
who have a Idea
p.s. it work also with 64 Bit
i have try ADO Recordset instead of INSERT INTO
Code: Select all
objRS := CreateObject( "ADODB.Recordset" )
objRS:Open( "Select * from [Sheet$]", oConnect, adOpenKeyset, adLockOptimistic )
DO WHILE !EOF()
aField := {}
aValue := {}
ii := 1
FOR ii := 1 TO iMax
cField := aStructure[ ii ] [ DBS_NAME ]
cType := aStructure[ ii ] [ DBS_TYPE ]
nPosi := FIELDPOS( cField )
xValue := FIELDGET( nPosi )
AADD(aField,cField)
AADD(aValue,xValue)
NEXT
objRS:AddNew(aField,aValue)
objRS:Update()
SKIP
ENDDO
objRS:Close()
objRS := NIL
---
while both seems to work i guess Problem is before ... how to create Table ... hm
who have a Idea
p.s. it work also with 64 Bit
have fun
Jimmy
Jimmy
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
hi,
got it
instead of
use
it was the "$" which was wrong ( have use it when read XLSx )
got it
instead of
Code: Select all
cSql := "INSERT INTO [Sheet1$] "+ cSelect + "VALUES ( "
Code: Select all
cSql := "INSERT INTO [Sheet1] "+ cSelect + "VALUES ( "
have fun
Jimmy
Jimmy
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
hi,
here working Sample Source include both Version : INSERT INTO or Recordset
Recordset work with "Update", not with "UpdateBatch" yet
INSERT INTO have Problem with DATE Format
none of them seems to work.
if someone find right Syntax please post it
here working Sample Source include both Version : INSERT INTO or Recordset
Recordset work with "Update", not with "UpdateBatch" yet
INSERT INTO have Problem with DATE Format
Code: Select all
xValue := DTOC( xValue )
xValue := DTOS( xValue ) + "000000"
xValue := HB_STOT( DTOS( xValue ) + "000000" )
if someone find right Syntax please post it
have fun
Jimmy
Jimmy
Re: ADORDD
Hi Jimmy
Error while I check your code
missing, but unknown function(s): SP_ADBFSTRUCT(),
ONDUMMY(), SETCURSORWAIT(), CALCPOS()
Error while I check your code
missing, but unknown function(s): SP_ADBFSTRUCT(),
ONDUMMY(), SETCURSORWAIT(), CALCPOS()
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- AUGE_OHR
- Posts: 2062
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: ADORDD
SP_ADBFSTRUCT() -> DBFSTRUCT()
ONDUMMY() is only for debug, delete it
Code: Select all
PROCEDURE SetCursorWait( cForm, lOn )
LOCAL nHwnd
DEFAULT lOn TO .F.
nHwnd := GetformHandle( cForm )
IF lOn = .T.
SetWindowCursor( nHwnd, IDC_WAIT )
ELSE
SetWindowCursor( nHwnd, IDC_ARROW )
ENDIF
RETURN
Code: Select all
FUNCTION CalcPos( nValue, iMax )
LOCAL nRet := 0
LOCAL nEvery
LOCAL xScale
IF iMax < 100
nEvery := 100 / iMax
nRet := nValue * nEvery
ELSE
nEvery := INT( iMax / 100 )
xScale := iMax * nEvery // Scale to 100%
nRet := iMax / xScale * nValue
ENDIF
RETURN ROUND( nRet, 0 )
have fun
Jimmy
Jimmy
Re: ADORDD
Hi
Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
So convert date to serial and store to excel
check code :
Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
So convert date to serial and store to excel
check code :
Code: Select all
#include "hmg.ch"
Function main()
SET DATE BRITI
SET CENT ON
msginfo( serial2dt(39448),"Date serial 44180 to date"+space(10))
msginfo( dt2serial(date()),"Today's Date Serial"+space(10))
return
Function serial2dt(xdt)
Local x_dateorigin, x_datenew
SET DATE BRITI
SET CENT ON
x_dateorigin := ctod("01/01/1900")
x_datenew :=( x_dateorigin + xdt ) - 2
Return dtoc( x_datenew )
Function dt2serial(xdt)
Local x_dateorigin, x_datenew
SET DATE BRITI
SET CENT ON
x_dateorigin := ctod("01/01/1900")
x_datenew := ( xdt -x_dateorigin ) + 2
Return x_datenew
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG