I have written a stored procedure to extract rows from an SQL table and I call the proc from VBA below id a snippet of the code I use.
::Stored Proc::
::VBA::
I never get a date match!
What am I doing wrong?
ps sorry about the long post, I couldn't think of a way of explaining without the code.
::Stored Proc::
Code:
CREATE PROCEDURE dbo.procMail
@Date datetime,
@Account int
AS
SELECT [LOADS OF FIELDS]
INTO MailTemp
FROM Orders
WHERE Orders.AccountNo = @Account AND Orders.[Order Status]='i' AND CONVERT(char(10),Orders.DespatchDate,103) = CONVERT(char(10),@Date,103)
EXEC procMailUpdate
GO
::VBA::
Code:
Rem #### Set Variables ####
dtmDate = Format(Now(), "dd/mm/yyyy")
intAccount = 18201
Rem #######################
Rem #### Run Stored Proc to Create Table ####
Set cmd = New ADODB.Command
cmd.ActiveConnection = adoCN
cmd.CommandText = "procMail"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("Date", adDBDate, adParamInput, , dtmDate)
cmd.Parameters.Append prm
Set prm = cmd.CreateParameter("Account", adInteger, adParamInput, , intAccount)
cmd.Parameters.Append prm
cmd.Execute
Set cmd = Nothing
Rem ##########################################
I never get a date match!
What am I doing wrong?
ps sorry about the long post, I couldn't think of a way of explaining without the code.