|
-
Jun 21st, 2005, 02:58 AM
#1
Thread Starter
Junior Member
Syntax error (Resolved)
"Syntax error converting datetime from character string"
i get this error when i am trying to pass 2 dates as parameters to a stored procedure in sql server
thanks for any help in advance
Last edited by Mystiquemint; Jun 21st, 2005 at 05:00 AM.
I respect Faith, but doubts are what get me educated
-
Jun 21st, 2005, 03:10 AM
#2
Re: Syntax error
It would be better if you would post your code.
-
Jun 21st, 2005, 03:12 AM
#3
Re: Syntax error
dates to a data base have to be in specific format, for access it is mm/dd/yy
i am not sure about sql, maybe the same or maybe yyyy/mm/dd
pete
-
Jun 21st, 2005, 03:13 AM
#4
Thread Starter
Junior Member
Re: Syntax error
.Parameters.Append .CreateParameter("@DateFrom", adVarChar, adParamInput, 25, CStr(MyArgs(1)))
.Parameters.Append .CreateParameter("@DateTo", adVarChar, adParamInput, 25, CStr(MyArgs(2)))
'Setup connection details and open connection to dB
Set mycon = New ADODB.Connection
mycon.ConnectionString = "File Name=" & App.Path & UDL_FILENAME
mycon.Open
Set .ActiveConnection = mycon
'Run command
.Execute
no matter how i pass these variables, i am getting the same error.
i mean i tried with the parameter datatype as adDate. no luck
I respect Faith, but doubts are what get me educated
-
Jun 21st, 2005, 03:17 AM
#5
-
Jun 21st, 2005, 03:20 AM
#6
Thread Starter
Junior Member
Re: Syntax error
date selected by the user from a datepicker
I respect Faith, but doubts are what get me educated
-
Jun 21st, 2005, 03:23 AM
#7
Re: Syntax error
Why are you converting them to string with CSTR?
-
Jun 21st, 2005, 03:24 AM
#8
Thread Starter
Junior Member
Re: Syntax error
i am just trying various combinations.............
even if i send the parameters as it is (with out converting) still i am getting the same error
I respect Faith, but doubts are what get me educated
-
Jun 21st, 2005, 03:43 AM
#9
Re: Syntax error
What type does the stored procedure use for the input parameters?
If possible, just change them to DateTime, so you can pass the parameters as dates, and not as text.
Your code needs a change too.
VB Code:
.Parameters.Append .CreateParameter("@DateFrom", adDate, adParamInput, 25, MyArgs(1))
.Parameters.Append .CreateParameter("@DateTo", adDate, adParamInput, 25, MyArgs(2))
-
Jun 21st, 2005, 03:47 AM
#10
Thread Starter
Junior Member
Re: Syntax error
well i tried that. didnt work. still the same error
I respect Faith, but doubts are what get me educated
-
Jun 21st, 2005, 04:17 AM
#11
Re: Syntax error
Can you post the code of the stored procedure?
-
Jun 21st, 2005, 04:34 AM
#12
Thread Starter
Junior Member
Re: Syntax error
finally, resolved. Thank you everybody for your help & time.
I respect Faith, but doubts are what get me educated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|