Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a Date to sql7 stored Procedure from VB6 2

Status
Not open for further replies.

jizviz

Programmer
Oct 13, 2002
26
0
0
US
I'm new to stored procedures and I'm having no luck passing a date parameter to my stored proc. Please HELP!!!
Here is my VB code:
DDate is the date that I'm trying to pass.

Set cmd = New Command
cmd.ActiveConnection = "RenewalsServer"
cmd.CommandText = "NoAnswerTest"
cmd.CommandType = adCmdStoredProc

Set param = cmd.CreateParameter("AcctNum", adDouble, adParamInput, , Val(AcctNum))
cmd.Parameters.Append param
Set param = cmd.CreateParameter("DDate", adDBTimeStamp, adParamInput, , Val(DDate))
cmd.Parameters.Append param

Set rsado = cmd.Execute

Here is the stored proc:

CREATE PROCEDURE NoAnswerTest
@AcctNum float,
@DDate datetime
AS
Insert Into tblCallBack
([Order],UserId,DDate)
Values
(@AcctNum,0,@DDate )

I get a result of 1/1/1900.

PLEASE HELP
Thanks for any input you may provide!!
 
adDBTimeStamp isn't right. Just do a cmd.parameters.refresh, you don't have to create the parameters.
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
I'm sorry I don't fully understand. How would my stored proc get the date I want to pass if I don't create the parameter? Thanks for your time and knowledge!!
 
What is wrong with calling you SP like this

NoAnswerTest " & val("AcctNum") & ", 0, '" & Val("DDate") & "'"

==========================
Date is a way to show you care
Time is a great healer
DateTime is just damn confusing

Tim
 
Now I get syntax error or access violation. Thanks!!!
 
Code VB this way:
Code:
Set cmd = New Command
With Cmd
   .ActiveConnection = "RenewalsServer"
   .CommandText = "NoAnswerTest"
   .CommandType = adCmdStoredProc
   .Parameters.refresh
   .Parameters(1)=TheAcct#
   .Parameters(2)=TheDate
   Set rsado = .Execute
End With
Do you really want the Acct # to be a float rather than int or varchar?
-Karl

[red] Cursors, triggers, user-defined functions and dynamic SQL are an axis of evil![/red]
[green]Life's uncertain...eat dessert first...www.deerfieldbakery.com[/green]
 
Thanks! Thanks! Thanks!!! I really appreciate everyone's help!! IT all works great now!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top