Re: Passing a Date parameter to a Parametrized query



Try this:

Dim par As ADODB.Parameter
cmdObj.CommandText = "qryUpdateDepositTemp"
cmdObj.CommandType = adCmdStoredProc
cmdObj.ActiveConnection = CurrentProject.Connection

Set par = New ADODB.Parameter
par.Type = adDateTime
par.Size = 8
par.Direction = adParamInput
par.Value = dDate
cmdObj.Parameters.Append par

cmdObj.Execute

--

Ken Snell
<MS ACCESS MVP>


"tuvi" <tuvi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:579A5487-B813-4F38-BCDB-43FB8CF061D2@xxxxxxxxxxxxxxxx
>I have the following query:
>
> PARAMETERS [dDate] DateTime;
> UPDATE DepositTemp SET DepositTemp.DepositDate = [dDate];
>
> And here is my code:
>
> cmdObj.CommandText = "qryUpdateDepositTemp"
> cmdObj.CommandType = adCmdStoredProc
> cmdObj.ActiveConnection = CurrentProject.Connection
> cmdObj.Execute Parameters:=dDate
>
> It always return error saying that wrong type of data!!!!
>
> I try the same above procedure for updating a different data type such as
> a
> Long Number and it works fine.... it just not works with a Date data type.
>
> Please help...
>
> I have Access 2003


.



Relevant Pages

  • Re: Passing a Date parameter to a Parametrized query
    ... I usually just create a Date data type dDate then pass to the query using ... The message still saying data type mismatched... ... > Dim par As ADODB.Parameter ... > Set par = New ADODB.Parameter ...
    (microsoft.public.access.modulesdaovba)
  • Re: Passing a Date parameter to a Parametrized query
    ... Dim command As ADODB.command ... > The message still saying data type mismatched... ... >> Dim par As ADODB.Parameter ... >> Set par = New ADODB.Parameter ...
    (microsoft.public.access.modulesdaovba)
  • Re: Parameter object with return value
    ... Here is my code sample to create and add a parameter to the parameters collection supporting several database models. ... This function works quite good, but I don't like the way, how I create an output parameter due to specifying a default return data type ). ... IDataParameter par = null; ... if (coll is OracleParameterCollection) ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Passing a Date parameter to a Parametrized query
    ... Dim par As ADODB.Parameter ... Set par = New ADODB.Parameter ... > cmdObj.CommandType = adCmdStoredProc ... > par.Value = dDate ...
    (microsoft.public.access.modulesdaovba)