Hello Folks !

I'm having trouble passing a datetime input/output parameter thru ADO/OLE
DB to a stored procedure. Please take a look at this weird behavior: (ASE

1) This is the SP.
create proc pr_teste
( @i int output,
@do datetime output)
delete from teste
insert into teste values (@i,convert(varchar,@do,109))
select @i = @i + 1000

2) teste has this columns:

Column_name Type Length
--------------- --------------- -----------
teste1 int 4
teste2 varchar 100

3) I'm running this code in VB6/SP5, using MDAC 2.7 SP1, ADO 2.7 and OLEDB provider 2.70.0015 (March 05, 2003, 12:05:12 PM):

Dim db As ADODB.Connection
Set db = New ADODB.Connection

db.Open "Provider=Sybase.ASEOLEDBProvider.2;Initial Catalog=dotbr;User
ID=sa;Data Source=dotbr;", "sa", ""

Dim cmd As ADODB.Command
Set cmd = New ADODB.Command

cmd.ActiveConnection = db
cmd.CommandText = "pr_teste"
cmd.CommandType = adCmdStoredProc

Dim intParam As ADODB.Parameter
Dim dateParam As ADODB.Parameter

Set intParam = cmd.CreateParameter("@i", adInteger, _
Set dateParam = cmd.CreateParameter("@do", adDBTimeStamp, _
cmd.Parameters.Append intParam
cmd.Parameters.Append dateParam

cmd.Parameters(0).Value = 123
cmd.Parameters(1).Value = CDate("01/01/2000")


Debug.Print cmd.Parameters(0).Value
Debug.Print cmd.Parameters(1).Value


4) The parameters values after cmd.execute are :

@i (cmd.Parameters(0).Value) = 1123 (OK !)
@do (cmd.Parameters(1).Value) = 11/27/2084 (????)

5) The table teste has this line:

teste1 teste2
----------- -----------------------------
123 Nov 27 2084 12:00:00:003AM

6) Why the datetime parameter has this value after executing the command ?
Am I missing something here ?
It seems that the OLE DB provider is messing up the value of the
datetime parameter, but the integer one is working correctly. Does anyone
have an idea of what's going on ?
I also tested input-only and output-only parameters and eveything did
ok. The problem is that we have so many SPs that use in/out params (back in
the old days when we used DB-Library, it was ok).
BTW, I ran the same code using ODBC and it worked fine, but the project
needs to be OLE DB, for various technical reasons.
Could anybody please help ?? Is this a BUG in the OLE DB provider ?

Thanks in advance,

Leandro Ramalho