pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hiroshi Inoue <inoue@tpf.co.jp>
To: Josh T <mortonjt@rochester.rr.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: VBA ADO Command Date Parameter Not Working
Date: Tue, 24 Nov 2009 07:22:15 +0900
Message-ID: <4B0B0B17.2000702@tpf.co.jp> (raw)
In-Reply-To: <4B0AAE9D.9030201@rochester.rr.com>
References: <4B0AAE9D.9030201@rochester.rr.com>

Josh T wrote:
> Hello,
> 
> I'm using the PSQL-ODBC driver from Excel 2002 VBA with a ADO Command 
> object.  What is the correct way to pass a date into a parameter so it 
> gets into the database correctly? - everything I've tried results in 
> 1900-05-07 added to the DB instead of the correct date. I also get 
> 1900-05-07 in the DB if I leave the date empty.  I've simplified my code 
> into the following test case - I've had no problems with other data 
> types.  I've already tried changing adDBDate, passing Date objects or 
> strings.
> 
> Thanks,
> Josh
> 
> Sub TestDateInsert()
>     Dim conn As ADODB.Connection
>     Dim cmd As ADODB.Command
> 
>     Set conn = New ADODB.Connection
>     conn.Open "DSN=PRHTest"
> 
>     Set cmd = New ADODB.Command
>     cmd.ActiveConnection = conn
>     cmd.CommandType = adCmdText
>     cmd.CommandText = "INSERT INTO test_table (test_date) VALUES (?);"
>     cmd.Parameters.Append cmd.CreateParameter("@test_date", adDBDate,
> adParamInput, , #11/23/2009#)


>     cmd.Execute , adExecuteNoRecords

It seemd 2 commas are needed, i.e.

	cmd.Execute ,, adExecuteNoRecords

regards,
Hiroshi Inoue

>     Set cmd = Nothing
>     conn.Close
>     Set conn = Nothing
> 
> End Sub
> 
> Database Table definition:
> 
> CREATE TABLE test_table (
>     test_date date NOT NULL
> );
>



view thread (7+ messages)  latest in thread

Message-ID: <4B0B0B17.2000702@tpf.co.jp>
Permalink:  ../4B0B0B17.2000702@tpf.co.jp/
Also on:    postgresql.org/message-id/4B0B0B17.2000702@tpf.co.jp

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: inoue@tpf.co.jp, mortonjt@rochester.rr.com
  Subject: Re: VBA ADO Command Date Parameter Not Working
  In-Reply-To: <4B0B0B17.2000702@tpf.co.jp>
  References: <4B0AAE9D.9030201@rochester.rr.com> <4B0B0B17.2000702@tpf.co.jp>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox