Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ADO Ms Access date\time
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 28 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rick Lipkin  
View profile  
 More options Feb 7, 6:00 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Tue, 7 Feb 2012 15:00:42 -0800 (PST)
Local: Tues, Feb 7 2012 6:00 pm
Subject: ADO Ms Access date\time
To All

Just upgraded to xHarbour 1.21 rev 9421 and when I assign a variable
to a Ms Access Date\Time field the ValType returns (T) ime ..

Here is the error log :

Application
===========
   Path and name: C:\Fox\PMOSQL-N\pmow32.Exe (32 bits)
   Size: 3,553,792 bytes
   Compiler version: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9421)
   FiveWin  Version: FWHX 11.12
   Windows version: 5.1, Build 2600 Service Pack 3

   Time from start: 0 hours 0 mins 30 secs
   Error occurred at: 02/07/2012, 15:51:34
   Error description: Error BASE/1075  Argument error: >
   Args:
     [   1] = T   12/30/1899 00:00:00.000
     [   2] = D   01/20/2023

The first value is oRs:Field("Start_date"):Value ( 2/7/2012 in the
Access table ) and returns the above [   1] = T   12/30/1899
00:00:00.000.

The second value was a variable assigned to Date() .. As you can see
when I compare the values a run-time error occurs.

This is a program that has been working fine for a long time ..
nothing has changed but xHarbour.

Any advice would be appreciated.

Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 8, 12:20 am
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Wed, 08 Feb 2012 05:20:42 GMT
Local: Wed, Feb 8 2012 12:20 am
Subject: Re: ADO Ms Access date\time
Hi Rick:

It's a known problem since "T" was introduced to xHarbour. Following
is my notes to developer list some time ago:

-- quote --
Date: Tue, 15 Nov 2011 08:17:42 +0700
From: Andi Jahja

> Please let us know which code if any will require addtional work.
> Walter, Andi, ..., any input?

IMHO, the following areas need urgent reviews:

 1. RDD
 2. RTL (incl. CT, which is an integrel part in xHarbour)

..........
-- unquote--

I believe the error you highlighted relates to RDD. Woud you please
post a self-contained program to demonstrate the error? We might as
well make a corresponding correction.

Andi

On Tue, 7 Feb 2012 15:00:42 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 8, 10:07 am
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Wed, 8 Feb 2012 07:07:49 -0800 (PST)
Local: Wed, Feb 8 2012 10:07 am
Subject: Re: ADO Ms Access date\time
On Feb 8, 12:20 am, andija...@internet.com (Andi Jahja) wrote:

Andi

Compile this program with the current xHarbour and you will see the
error on the date comparisons ..

Rick Lipkin

// AccessDB.prg
// creating an access database from code
// showing how date time field translates incorrectly

STATIC lOK

//-------------

Local catNewDB,xProvider,xConnect,cFile,aDir,dExe,cDefa,mStart
Local oCn,cSql,oErr,oRsUser,cLOGIN,Saying
Local cTitle,oWnd1,oBrw,oCol,nYear,dCreatedate

setmode( 25, 80 )

lOK := .F.

//-- get timestamp on .exe //

cFILE := HB_ARGV(0)
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL
SET DEFA to ( cDEFA )

SET DELETED on
SET CENTURY on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

Ferase( cDefa+"\Rick.mdb" )

xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"\Rick.mdb"
xPASSWORD := "dec2011"

// create the adox object
Try
   catNewDB := CreateObject("ADOX.Catalog")
Catch
   ? "Could not Create ADOX object"
   wait
   Return(.f.)
End try

// create the table Rick.mdb
Try
  catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet
OLEDB:Engine Type=5;Jet OLEDB:Database Password='+xPASSWORD )
Catch
   ? "Could not create the table "+xSource
   wait
  Return(.f.)
End Try

// global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet
OLEDB:Database Password='+xPASSWORD

Try
  oCn  := CREATEOBJECT( "ADODB.Connection" )
Catch
   ? "Could not create the ADO object for connection"
   wait
End Try

TRY
   oCn:Open( xCONNECT )
CATCH oErr
   ? "Could not open a Connection to Database "+xSource
   wait
  RETURN(.F.)
END TRY

cSQL := "CREATE TABLE USERINFO"
cSQL += "( "
cSQL += "[USEREID] char(18) NOT NULL, "
cSQL += "[USERID] char(8) NULL, "
cSQL += "[READONLY] char(1) NULL, "
cSQL += "[WRITEONLY] char(1) NULL, "
cSQL += "[SUPER] char(1) NULL, "
cSQL += "[LASTLOG] datetime NULL, "
cSQL += "[CREATEDATE] datetime NULL, "
cSQL += "[PASSWORD] char(10) NULL, "
cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( USEREID )"
cSQL += " )"

// create the table Userinfo
// with primary key

Try
   oCn:Execute( cSQL )
Catch
   ? "Table USERINFO Failed"
   wait
   Return(.f.)
End try

oCn:Close()
oCn := nil

cLOGIN := upper(NetName(.T.))+space(8)
cLOGIN := SUBSTR(cLOGIN,1,8)

// open the Userinfo table record set
// append the first record
// could have also used a connection and the INSERT command

oRsUser := TOleAuto():New( "ADODB.Recordset" )
oRsUser:CursorType     := 1        // opendkeyset
oRsUser:CursorLocation := 3        // local cache
oRsUser:LockType       := 3        // lockoportunistic

// check for very first user

cSQL := "SELECT * FROM USERINFO"
TRY
   oRsUser:Open( cSQL, xCONNECT )
CATCH oErr
   ? "Error in Opening USERINFO table here"
   wait
   RETURN(.F.)
END TRY

If oRsUser:eof
   oRsUser:AddNew()

   oRsUser:Fields("UserEid"):Value    := "011111111111111111"
   oRsUser:Fields("UserId"):Value     := cLOGIN
   oRsUser:Fields("ReadOnly"):Value   := "Y"
   oRsUser:Fields("WriteOnly"):Value  := "Y"
   oRsUser:Fields("Super"):Value      := "Y"
   oRsUser:Fields("CreateDate"):Value := dtoc(DATE())+" "+time()
   oRsUser:Fields("LastLog"):Value    := dtoc(DATE())+" "+time()
   oRsUser:Fields("PassWord"):Value   := "ADMIN"

   oRsUser:Update()
Endif

dCreateDate := oRsUser:Fields("CreateDate"):Value
oRsUser:Close()

? dCreateDate
? ValType( dCreateDate )
wait

? (date()+3) - dCreateDate   // errors here with current xHarbour
wait

Return(nil)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 8, 4:58 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Wed, 08 Feb 2012 21:58:11 GMT
Local: Wed, Feb 8 2012 4:58 pm
Subject: Re: ADO Ms Access date\time
Hi Rick:

I've compiled the program but: "cannot create rick.mdb" error.
FYI, I have nothing installed in my machine. Do I have to install
something to be able to create rick.mdb? Sorry, frankly I never play
with this stuff before.

Looks like this is an OLE problem (not RDD as I said before). I think
I almost there.

Please advise me what to install to run your program (somesort of
server?)

Thanks
Andi

On Wed, 8 Feb 2012 07:07:49 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 8, 5:33 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Wed, 08 Feb 2012 22:33:05 GMT
Local: Wed, Feb 8 2012 5:33 pm
Subject: Re: ADO Ms Access date\time
Forget all my previous message below. It is not relevant :(

The self-contained program is as follows:

// begin
proc main()
? DATE() - DATETIME( 2012, 02, 01, 18, 42, 16  )
// end

There is something to correct in the VM module.
I am working on it now.

Andi

On Wed, 08 Feb 2012 21:58:11 GMT, andija...@internet.com (Andi Jahja)
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ron Pinkas  
View profile  
 More options Feb 8, 5:39 pm
Newsgroups: comp.lang.xharbour
From: "Ron Pinkas" <Ron.Pinkas_remove_th...@xHarbour.com>
Date: Wed, 8 Feb 2012 14:39:06 -0800
Local: Wed, Feb 8 2012 5:39 pm
Subject: Re: ADO Ms Access date\time
Andi,

The error appears not related to RDD, it appears to suggest that we simply
are missing proper DATETIME support in hb_vmGreater() (and maybe other
similar operators).

Ron


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 8, 6:14 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Wed, 8 Feb 2012 15:14:58 -0800 (PST)
Local: Wed, Feb 8 2012 6:14 pm
Subject: Re: ADO Ms Access date\time
On Feb 8, 5:39 pm, "Ron Pinkas" <Ron.Pinkas_remove_th...@xHarbour.com>
wrote:

Ron, Andi

I appreciate your support .. Andi .. just curious what breakpoint in
my program was your error caught .. To my knowledge the Microsoft Jet
oledb provider is part of all Windows OS's .. should not matter if you
are running 32 or 64 bit ??

Thanks
Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 8, 7:20 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Thu, 09 Feb 2012 00:20:28 GMT
Local: Wed, Feb 8 2012 7:20 pm
Subject: Re: ADO Ms Access date\time
Hi Rick:

Would you please try after my latest commit:

  2012-02-09 07:05 UTC+0700 Andi Jahja <xharbour/AT/telkom/net/id>

Andi

On Wed, 8 Feb 2012 15:14:58 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 8, 7:21 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Thu, 09 Feb 2012 00:21:44 GMT
Local: Wed, Feb 8 2012 7:21 pm
Subject: Re: ADO Ms Access date\time
Ron,

Yes, you're right.
I have just commited changes related to VM routines.

Andi

On Wed, 8 Feb 2012 14:39:06 -0800, "Ron Pinkas"


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 9, 11:15 am
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Thu, 9 Feb 2012 08:15:25 -0800 (PST)
Local: Thurs, Feb 9 2012 11:15 am
Subject: Re: ADO Ms Access date\time
On Feb 8, 7:21 pm, andija...@internet.com (Andi Jahja) wrote:

Andi

I was just now able to compile your commit with version 9430 .. The
math part works fine now .. however the comparison fails ..

I have modified your example and you will see the last expression
errors when comparing the two values ..

Rick Lipkin

// begin

*Proc Main()
local dDATE

dDate :=  DATETIME( 2012, 02, 01, 18, 42, 16  )

? "Valtype dDate"
? ValType( dDate )
Wait

? "Value of dDate"
? dDate
Wait

? DATE() - dDate
Wait

If dDate < date()
   ? "dDate < date()"
   Wait
Endif

// end

----------------------------- xHarbour Error Log
------------------------------

Date...............: 02/09/12
Time...............: 11:08:27

Application name...: C:\Fox\Access2003\Test.Exe
Workstation name...: DEMO-PC
Available memory...: 1440288
Current disk.......: C
Current directory..: Fox\Access2003
Free disk space....: 109635043328

Operating system...: Windows XP Home Edition 5.01.2600 Service Pack 3
xHarbour version...: xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 9430)
xHarbour built on..: Feb  9 2012 13:57:05
C/C++ compiler.....: Borland C++ 5.5.1 (32 bit)
Multi Threading....: NO
VM Optimization....: 2

Current Area ......:1

-------------------- Internal Error Handling Information
---------------------

Subsystem Call ....: BASE
System Code .......: 1073
Default Status ....: .F.
Description .......: Argument error
Operation .........: <
Arguments .........:  [ 1] = Type: T Val: 20120201184216.000 [ 2] =
Type: D Val: 20120209
Involved File .....:
Dos Error Code ....: 0

 Trace Through:
----------------
TEST                  :      19 in Module: Test.prg

############################## Video Screen Dump
##############################

+-------------------------------------------------------------------------- ------
+
|
|
|Valtype
dDate
|
|
T
|
|Press any key to
continue...                                                    |
|Value of
dDate
|
|02/01/12
18:42:16.000
|
|Press any key to
continue...                                                    |
|
7.220648
|
|Press any key to
continue...                                                    |
|Error BASE/1073  Argument error: < Arguments: ( [ 1] = Type: T Val:
201202011842|
|16.000 [ 2] = Type: D Val:
20120209)                                            |
|
|
|Error at ...: TEST(19) in Module: Test.prg


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 9, 1:22 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Thu, 09 Feb 2012 18:22:13 GMT
Local: Thurs, Feb 9 2012 1:22 pm
Subject: Re: ADO Ms Access date\time
Hi Rick,

I am working on it. All relational comparison logic for datetime
values are to be modified ( >, >=, <=, !=, etc). I'll come back to the
group once finished.

Andi

On Thu, 9 Feb 2012 08:15:25 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 9, 2:17 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Thu, 9 Feb 2012 11:17:20 -0800 (PST)
Local: Thurs, Feb 9 2012 2:17 pm
Subject: Re: ADO Ms Access date\time
On Feb 9, 1:22 pm, andija...@internet.com (Andi Jahja) wrote:

Andi

Thank you for your help and diligence !

Rick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Enrico Maria Giordano  
View profile  
 More options Feb 9, 2:27 pm
Newsgroups: comp.lang.xharbour
From: "Enrico Maria Giordano" <e.m.giord...@emagsoftware.it>
Date: Thu, 9 Feb 2012 20:27:38 +0100
Local: Thurs, Feb 9 2012 2:27 pm
Subject: Re: ADO Ms Access date\time

> I am working on it. All relational comparison logic for datetime
> values are to be modified ( >, >=, <=, !=, etc). I'll come back to the
> group once finished.

Thank you!

EMG

--
EMAG Software Homepage:     http://www.emagsoftware.it
The EMG's ZX-Spectrum Page: http://www.emagsoftware.it/spectrum
The Best of Spectrum Games: http://www.emagsoftware.it/tbosg
The EMG Music page:         http://www.emagsoftware.it/emgmusic


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 9, 2:27 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Thu, 09 Feb 2012 19:27:36 GMT
Local: Thurs, Feb 9 2012 2:27 pm
Subject: Re: ADO Ms Access date\time
Hi Rick,

It should be OK now after:

2012-02-10 02:25 UTC+0700 Andi Jahja <xharbour/AT/telkom/net/id>
  ! source/vm/hvm.c
    ! fixed the comparison logic related to DATETIME values
      ( <, >, <=, >=, =, ==, != )

Andi

On Thu, 9 Feb 2012 11:17:20 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 9, 3:20 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Thu, 9 Feb 2012 12:20:05 -0800 (PST)
Local: Thurs, Feb 9 2012 3:20 pm
Subject: Re: ADO Ms Access date\time
On Feb 9, 2:27 pm, andija...@internet.com (Andi Jahja) wrote:

Andi

I will test your commit as quick as I can ..Dumb question .. is there
a PICTURE clause that will take a datetime string and convert it to
view just a date like 02/09/2012 ?

Thank You!
Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 9, 5:19 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Thu, 9 Feb 2012 14:19:09 -0800 (PST)
Local: Thurs, Feb 9 2012 5:19 pm
Subject: Re: ADO Ms Access date\time
On Feb 9, 3:20 pm, Rick Lipkin <r1.1...@live.com> wrote:

Andi

Your fix WORKED .. however when my DateTime value writes back to the
Access table it stores 12:00 am instead of the correct Date :(

I hope this is not turning out to be too much of a burden .. to
maintain legacy compatibility I hope you can make the table write back
and save correctly with the date ..

See one of the links below for the table view ..

Thanks
Rick

http://www.freeimagehosting.net/n5lrc

[url=http://www.freeimagehosting.net/n5lrc][img]http://
www.freeimagehosting.net/t/n5lrc.jpg[/img][/url]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 9, 6:05 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Thu, 09 Feb 2012 23:05:03 GMT
Local: Thurs, Feb 9 2012 6:05 pm
Subject: Re: ADO Ms Access date\time
On Thu, 9 Feb 2012 14:19:09 -0800 (PST), Rick Lipkin

Hi Rick,

I've seen the pic, but could you please how to reproduced the error
please?

Andi


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 10, 1:02 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Fri, 10 Feb 2012 10:02:41 -0800 (PST)
Local: Fri, Feb 10 2012 1:02 pm
Subject: Re: ADO Ms Access date\time
On Feb 9, 6:05 pm, andija...@internet.com (Andi Jahja) wrote:

Andi

Here is the same code as before only difference is it writes to the
Access Database. I do not know why the Access database would not be
created on your machine .. I have had universal good luck with this
code on just about every machine I have tried.

You will need Ms Access to open Rick.mdb to view the UserInfo Table.
You can download the free trial Office 2010 Professional trial from
MS :

http://office.microsoft.com/en-us/try/

If you prefer I can e-mail you the Access table .. but you will still
need to Install MS Access to view the table.

Let me know if there is anything I can do ..

Thanks
Rick

// AccessDBx.prg
// creating an access database from code
// showing how date time field translates incorrectly

STATIC lOK

//-------------
*Func Main()

Local catNewDB,xProvider,xConnect,cFile,aDir,dExe,cDefa,mStart
Local oCn,cSql,oErr,oRsUser,cLOGIN,Saying
Local cTitle,oWnd1,oBrw,oCol,nYear,dCreatedate

setmode( 25, 80 )

lOK := .F.

//-- get timestamp on .exe //

cFILE := HB_ARGV(0)
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL
SET DEFA to ( cDEFA )

SET DELETED on
SET CENTURY on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

Ferase( cDefa+"\Rick.mdb" )

xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"\Rick.mdb"

// create the adox object
Try
   catNewDB := CreateObject("ADOX.Catalog")
Catch
   ? "Could not Create ADOX object"
   wait
   Return(.f.)
End try

// create the table Rick.mdb
Try
  catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet
OLEDB:Engine Type=5' )
Catch
   ? "Could not create the table "+xSource
   wait
  Return(.f.)
End Try

// global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet
OLEDB:Database'

Try
  oCn  := CREATEOBJECT( "ADODB.Connection" )
Catch
   ? "Could not create the ADO object for connection"
   wait
End Try

TRY
   oCn:Open( xCONNECT )
CATCH oErr
   ? "Could not open a Connection to Database "+xSource
   wait
  RETURN(.F.)
END TRY

cSQL := "CREATE TABLE USERINFO"
cSQL += "( "
cSQL += "[USEREID] char(18) NOT NULL, "
cSQL += "[USERID] char(8) NULL, "
cSQL += "[READONLY] char(1) NULL, "
cSQL += "[WRITEONLY] char(1) NULL, "
cSQL += "[SUPER] char(1) NULL, "
cSQL += "[LASTLOG] datetime NULL, "
cSQL += "[CREATEDATE] datetime NULL, "
cSQL += "[PASSWORD] char(10) NULL, "
cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( USEREID )"
cSQL += " )"

// create the table Userinfo
// with primary key

Try
   oCn:Execute( cSQL )
Catch
   ? "Table USERINFO Failed"
   wait
   Return(.f.)
End try

oCn:Close()
oCn := nil

cLOGIN := upper(NetName(.T.))+space(8)
cLOGIN := SUBSTR(cLOGIN,1,8)

// open the Userinfo table record set
// append the first record
// could have also used a connection and the INSERT command

oRsUser := TOleAuto():New( "ADODB.Recordset" )
oRsUser:CursorType     := 1        // opendkeyset
oRsUser:CursorLocation := 3        // local cache
oRsUser:LockType       := 3        // lockoportunistic

// check for very first user

cSQL := "SELECT * FROM USERINFO"
TRY
   oRsUser:Open( cSQL, xCONNECT )
CATCH oErr
   ? "Error in Opening USERINFO table here"
   wait
   RETURN(.F.)
END TRY

If oRsUser:eof
   oRsUser:AddNew()

   oRsUser:Fields("UserEid"):Value    := "011111111111111111"
   oRsUser:Fields("UserId"):Value     := cLOGIN
   oRsUser:Fields("ReadOnly"):Value   := "Y"
   oRsUser:Fields("WriteOnly"):Value  := "Y"
   oRsUser:Fields("Super"):Value      := "Y"
   oRsUser:Fields("CreateDate"):Value := dtoc(DATE())+" "+time()
   oRsUser:Fields("LastLog"):Value    := dtoc(DATE())+" "+time()
   oRsUser:Fields("PassWord"):Value   := "ADMIN"

   oRsUser:Update()
Endif

dCreateDate := oRsUser:Fields("CreateDate"):Value

? "Value of dCreateDate"
? dCreateDate
wait

? " "
? "ValType of dCreateDate"
? ValType( dCreateDate )
wait

? " "
? "Date()+3) - dCreateDate"
? (date()+3) - dCreateDate   // errors here with current xHarbour
wait

? " "
? "dCreateDate > Date()+4000"
? dCreateDate > DATE()+4000
Wait

oRsUser:Fields("CreateDate"):Value := dCreateDate
oRsUser:Update()
oRsUser:Close()

? " "
? "Open Rick.Mdb with Ms Access and Table UserInfo to view CreateDate"
Wait

Return(nil)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 10, 1:37 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Fri, 10 Feb 2012 10:37:57 -0800 (PST)
Local: Fri, Feb 10 2012 1:37 pm
Subject: Re: ADO Ms Access date\time
On Feb 10, 1:02 pm, Rick Lipkin <r1.1...@live.com> wrote:

Andy

You can try it like this .. without needing to download MS Access ..
still need to figure out why this code will not create the .mdb .. It
should work on any system.

Rick

// AccessDBx.prg
// creating an access database from code
// showing how date time field translates incorrectly

STATIC lOK

//-------------
*Func Main()

Local catNewDB,xProvider,xConnect,cFile,aDir,dExe,cDefa,mStart
Local oCn,cSql,oErr,oRsUser,cLOGIN,Saying
Local cTitle,oWnd1,oBrw,oCol,nYear,dCreatedate,xCreateDate

setmode( 25, 80 )

lOK := .F.

//-- get timestamp on .exe //

cFILE := HB_ARGV(0)
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL
SET DEFA to ( cDEFA )

SET DELETED on
SET CENTURY on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

Ferase( cDefa+"\Rick.mdb" )

xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"\Rick.mdb"
xPASSWORD := "dec2011"

// create the adox object
Try
   catNewDB := CreateObject("ADOX.Catalog")
Catch
   ? "Could not Create ADOX object"
   wait
   Return(.f.)
End try

// create the table Rick.mdb
Try
  catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet
OLEDB:Engine Type=5' ) //;Jet OLEDB:Database Password='+xPASSWORD )
Catch
   ? "Could not create the table "+xSource
   wait
  Return(.f.)
End Try

// global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet
OLEDB:Database' // Password='+xPASSWORD

Try
  oCn  := CREATEOBJECT( "ADODB.Connection" )
Catch
   ? "Could not create the ADO object for connection"
   wait
End Try

TRY
   oCn:Open( xCONNECT )
CATCH oErr
   ? "Could not open a Connection to Database "+xSource
   wait
  RETURN(.F.)
END TRY

cSQL := "CREATE TABLE USERINFO"
cSQL += "( "
cSQL += "[USEREID] char(18) NOT NULL, "
cSQL += "[USERID] char(8) NULL, "
cSQL += "[READONLY] char(1) NULL, "
cSQL += "[WRITEONLY] char(1) NULL, "
cSQL += "[SUPER] char(1) NULL, "
cSQL += "[LASTLOG] datetime NULL, "
cSQL += "[CREATEDATE] datetime NULL, "
cSQL += "[PASSWORD] char(10) NULL, "
cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( USEREID )"
cSQL += " )"

// create the table Userinfo
// with primary key

Try
   oCn:Execute( cSQL )
Catch
   ? "Table USERINFO Failed"
   wait
   Return(.f.)
End try

oCn:Close()
oCn := nil

cLOGIN := upper(NetName(.T.))+space(8)
cLOGIN := SUBSTR(cLOGIN,1,8)

// open the Userinfo table record set
// append the first record
// could have also used a connection and the INSERT command

oRsUser := TOleAuto():New( "ADODB.Recordset" )
oRsUser:CursorType     := 1        // opendkeyset
oRsUser:CursorLocation := 3        // local cache
oRsUser:LockType       := 3        // lockoportunistic

// check for very first user

cSQL := "SELECT * FROM USERINFO"
TRY
   oRsUser:Open( cSQL, xCONNECT )
CATCH oErr
   ? "Error in Opening USERINFO table here"
   wait
   RETURN(.F.)
END TRY

If oRsUser:eof
   oRsUser:AddNew()

   oRsUser:Fields("UserEid"):Value    := "011111111111111111"
   oRsUser:Fields("UserId"):Value     := cLOGIN
   oRsUser:Fields("ReadOnly"):Value   := "Y"
   oRsUser:Fields("WriteOnly"):Value  := "Y"
   oRsUser:Fields("Super"):Value      := "Y"
   oRsUser:Fields("CreateDate"):Value := dtoc(DATE())+" "+time()
   oRsUser:Fields("LastLog"):Value    := dtoc(DATE())+" "+time()
   oRsUser:Fields("PassWord"):Value   := "ADMIN"

   oRsUser:Update()
Endif

dCreateDate := oRsUser:Fields("CreateDate"):Value

? "Value of dCreateDate"
? dCreateDate
wait

? " "
? "ValType of dCreateDate"
? ValType( dCreateDate )
wait

? " "
? "Date()+3) - dCreateDate"
? (date()+3) - dCreateDate   // errors here with current xHarbour
wait

? " "
? "dCreateDate > Date()+4000"
? dCreateDate > DATE()+4000
Wait

oRsUser:Fields("CreateDate"):Value := dCreateDate
oRsUser:Update()

xCreateDate := oRsUser:Fields("CreateDate"):Value
oRsUser:Close()

? " "
? "Create Date in Table"
? xCreateDate
Wait

Return(nil)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 10, 3:15 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Fri, 10 Feb 2012 20:15:23 GMT
Local: Fri, Feb 10 2012 3:15 pm
Subject: Re: ADO Ms Access date\time
Rick,

Many thanks for your help tracing the bug.
I was able to create and run the program, thus I see what you meant.

I am trying to fix it now.

Andi

On Fri, 10 Feb 2012 10:37:57 -0800 (PST), Rick Lipkin

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 10, 3:27 pm
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Fri, 10 Feb 2012 20:27:26 GMT
Local: Fri, Feb 10 2012 3:27 pm
Subject: Re: ADO Ms Access date\time
Rick,

Would you mind try again after my latest commit please:

 2012-02-11 03:25 UTC+0700 Andi Jahja <xharbour/AT/telkom/net/id>
  ! source/rtl/hbwinole.c
    ! fixed handling DATETIME values (bug report by Rick Lipkin)

Andi

On Fri, 10 Feb 2012 10:37:57 -0800 (PST), Rick Lipkin

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 11, 9:28 am
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Sat, 11 Feb 2012 06:28:07 -0800 (PST)
Local: Sat, Feb 11 2012 9:28 am
Subject: Re: ADO Ms Access date\time
Andi

You are REAL CLOSE .. the only problem is when you extract the
DateTime Value from the table in a Get and save it back to the
Table .. the field in the table that should have been changed has not
been updated or changed.

I have modified my example to demonstrate .. change the Datetime value
in the Get and you will notice it is not saved back to the Table.

Rick

// AccessDBx.prg
// creating an access database from code
// showing how date time field translates incorrectly

STATIC lOK

//-------------
*Func Main()

Local catNewDB,xProvider,xConnect,cFile,aDir,dExe,cDefa,mStart
Local oCn,cSql,oErr,oRsUser,cLOGIN,Saying
Local cTitle,oWnd1,oBrw,oCol,nYear,dCreatedate,xCreateDate

setmode( 25, 80 )

lOK := .F.

//-- get timestamp on .exe //

cFILE := HB_ARGV(0)
aDIR  := DIRECTORY( cFILE )

// where .exe started from is default directory //

mSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,mSTART-1)

aDIR := NIL
SET DEFA to ( cDEFA )

SET DELETED on
SET CENTURY on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

Ferase( cDefa+"\Rick.mdb" )

xPROVIDER := "Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"\Rick.mdb"
xPASSWORD := "dec2011"

// create the adox object
Try
   catNewDB := CreateObject("ADOX.Catalog")
Catch
   ? "Could not Create ADOX object"
   wait
   Return(.f.)
End try

// create the table Rick.mdb
Try
  catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet
OLEDB:Engine Type=5' ) //;Jet OLEDB:Database Password='+xPASSWORD )
Catch
   ? "Could not create the table "+xSource
   wait
  Return(.f.)
End Try

// global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Jet
OLEDB:Database' // Password='+xPASSWORD

Try
  oCn  := CREATEOBJECT( "ADODB.Connection" )
Catch
   ? "Could not create the ADO object for connection"
   wait
End Try

TRY
   oCn:Open( xCONNECT )
CATCH oErr
   ? "Could not open a Connection to Database "+xSource
   wait
  RETURN(.F.)
END TRY

cSQL := "CREATE TABLE USERINFO"
cSQL += "( "
cSQL += "[USEREID] char(18) NOT NULL, "
cSQL += "[USERID] char(8) NULL, "
cSQL += "[READONLY] char(1) NULL, "
cSQL += "[WRITEONLY] char(1) NULL, "
cSQL += "[SUPER] char(1) NULL, "
cSQL += "[LASTLOG] datetime NULL, "
cSQL += "[CREATEDATE] datetime NULL, "
cSQL += "[PASSWORD] char(10) NULL, "
cSQL += "CONSTRAINT PK_USERINFO PRIMARY KEY ( USEREID )"
cSQL += " )"

// create the table Userinfo
// with primary key

Try
   oCn:Execute( cSQL )
Catch
   ? "Table USERINFO Failed"
   wait
   Return(.f.)
End try

oCn:Close()
oCn := nil

cLOGIN := upper(NetName(.T.))+space(8)
cLOGIN := SUBSTR(cLOGIN,1,8)

// open the Userinfo table record set
// append the first record
// could have also used a connection and the INSERT command

oRsUser := TOleAuto():New( "ADODB.Recordset" )
oRsUser:CursorType     := 1        // opendkeyset
oRsUser:CursorLocation := 3        // local cache
oRsUser:LockType       := 3        // lockoportunistic

// check for very first user

cSQL := "SELECT * FROM USERINFO"
TRY
   oRsUser:Open( cSQL, xCONNECT )
CATCH oErr
   ? "Error in Opening USERINFO table here"
   wait
   RETURN(.F.)
END TRY

If oRsUser:eof
   oRsUser:AddNew()

   oRsUser:Fields("UserEid"):Value    := "011111111111111111"
   oRsUser:Fields("UserId"):Value     := cLOGIN
   oRsUser:Fields("ReadOnly"):Value   := "Y"
   oRsUser:Fields("WriteOnly"):Value  := "Y"
   oRsUser:Fields("Super"):Value      := "Y"
   oRsUser:Fields("CreateDate"):Value := dtoc(DATE())+" "+time()
   oRsUser:Fields("LastLog"):Value    := dtoc(DATE())+" "+time()
   oRsUser:Fields("PassWord"):Value   := "ADMIN"

   oRsUser:Update()
Endif

? Version()

dCreateDate := oRsUser:Fields("CreateDate"):Value
? " "
? "Value of dCreateDate"
? dCreateDate
wait

? " "
? "ValType of dCreateDate"
? ValType( dCreateDate )
wait

? " "
? "Date()+3) - dCreateDate"
? (date()+3) - dCreateDate   // errors here with current xHarbour
wait

? " "
? "dCreateDate > Date()+4000"
? dCreateDate > DATE()+4000
Wait

oRsUser:Fields("CreateDate"):Value := dCreateDate
oRsUser:Update()

xCreateDate := oRsUser:Fields("CreateDate"):Value

? " "
? "Create Date in Table"
? xCreateDate
Wait

@ 23,0 Say "Change the date  "get xCreateDate
Read

oRsUser:Fields("CreateDate"):Value := xCreateDate
oRsUser:Update()

xCreateDate := oRsUser:Fields("CreateDate"):Value

? " "
? "xCreatedate from table after Get"
? xCreateDate
Wait

Return(nil)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andi Jahja  
View profile  
 More options Feb 12, 3:14 am
Newsgroups: comp.lang.xharbour
From: andija...@internet.com (Andi Jahja)
Date: Sun, 12 Feb 2012 08:14:28 GMT
Local: Sun, Feb 12 2012 3:14 am
Subject: Re: ADO Ms Access date\time
Rick,

OK, I see problems on source/rtl/tget.prg and source/rtl/transfrm.c.
I'll try my best to solve it next week. Meanwhile, if there is any
volunteer, by all means, please ....

Andi

On Sat, 11 Feb 2012 06:28:07 -0800 (PST), Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 12, 12:08 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Sun, 12 Feb 2012 09:08:57 -0800 (PST)
Local: Sun, Feb 12 2012 12:08 pm
Subject: Re: ADO Ms Access date\time
On Feb 12, 3:14 am, andija...@internet.com (Andi Jahja) wrote:

> Rick,

> OK, I see problems on source/rtl/tget.prg and source/rtl/transfrm.c.
> I'll try my best to solve it next week. Meanwhile, if there is any
> volunteer, by all means, please ....

> Andi

Andi

Thank you again for your Help and diligence!!

Rick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rick Lipkin  
View profile  
 More options Feb 21, 4:52 pm
Newsgroups: comp.lang.xharbour
From: Rick Lipkin <r1.1...@live.com>
Date: Tue, 21 Feb 2012 13:52:53 -0800 (PST)
Local: Tues, Feb 21 2012 4:52 pm
Subject: Re: ADO Ms Access date\time
On Feb 12, 12:08 pm, Rick Lipkin <r1.1...@live.com> wrote:

> On Feb 12, 3:14 am, andija...@internet.com (Andi Jahja) wrote:

> > Rick,

> > OK, I see problems on source/rtl/tget.prg and source/rtl/transfrm.c.
> > I'll try my best to solve it next week. Meanwhile, if there is any
> > volunteer, by all means, please ....

> > Andi

> Andi

> Thank you again for your Help and diligence!!

> Rick

Just a quick follow up to any Developer .. Andi has done a wonderful
job with only this one last modification to complete..

Anyone ??

Thanks
Rick Lipkin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 28   Newer >
« Back to Discussions « Newer topic     Older topic »