 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 23rd, 2004, 11:15 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
syntax error
Hi there
I'm getting the following error with my code
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC SQL Server Driver][SQL Server]Syntax error converting datetime from character string.
I'm not sure why this is happening:
I've got a sproc on the line with the error:
set strSQL = con.execute("[up_insert_enq] '" & strTitle & "' , '" & strName & "' , '" & strEmail & "' , '" & strTel & "' , '" & strContact & "' , '" & strEnquiry & "', '" & strDate & "'")
and above I've declared strDate as
strDate = now()
Hoping someone can help
thanks
Adam
|
|

January 23rd, 2004, 11:23 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
"#' & strDate & '#"
I believe this is correct to pass a date
J
|
|

January 23rd, 2004, 11:28 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
# is only for Access dates. SQL Server uses '
Sounds like a date format problem. Can you do a Response.Write strSQL so we can see what date format is being sent to the db?
Personally, I always use a command object to run the stored proc, coz then you can set a parameter's type as a datetime and pass it a date variable and all goes swimmingly.
hth
Phil
|
|

January 23rd, 2004, 11:31 AM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the correction...on other thought...is now() valid syntax or should strDate=Date
where Date is retrieved from the server...particularly if the database date field is a date only and not a date/time
JW
|
|

January 23rd, 2004, 11:55 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
All sorted now - thanks for your input guys.
Phil, how do you use a command object to run the sproc?
thanks
Adam
|
|

January 26th, 2004, 06:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Adam, here's an example of using a command object to run a stored proc
Code:
'...code here to open a connection
Set adoCommand = Server.CreateObject("ADODB.Command")
With adoCommand
.ActiveConnection = adoConnection ' connection object here
.CommandType = adCmdStoredProc
.CommandText = "stored procedure name"
' parameters go here
'(ParamName, DataType, Direction, Size (only for string types), value)
.Parameters.Append .CreateParameter("AnInt", adInteger, adParamInput, , 0)
.Parameters.Append .CreateParameter("AChar", adChar, adParamInput, 8, "ABCDEFGH")
.Parameters.Append .CreateParameter("ADate", adDBTimeStamp, adParamInput, , Now)
.Parameters.Append .CreateParameter("AVarChar", adVarChar, adParamInput, 80, "x")
' now run the stored proc - use adExecuteNoRecords for INSERT/UPDATE where
' no recordset is returned. For other types like SELECT, first create a
' Recordset object, then use
' Set rsObj = .Execute
.Execute , , adExecuteNoRecords
End With
By passing dates in this way you avoid the problem of the date being converted to a string and back to a date again.
hth
Phil
|
|

January 26th, 2004, 09:10 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Great, thanks Phil.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Parse error: syntax error, unexpected T_ELSE in /h |
vipin k varghese |
BOOK: XSLT Programmer's Reference, 2nd Edition |
4 |
September 29th, 2011 01:19 AM |
| Ch 4: Parse error: syntax error, unexpected T_SL |
hanizar77 |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
0 |
June 23rd, 2008 09:17 PM |
| Parse error: syntax error, unexpected T_STRING |
ginost7 |
Beginning PHP |
1 |
November 9th, 2007 02:51 AM |
| VB Error: Syntax Error or Access Violation |
codehappy |
VB How-To |
7 |
October 3rd, 2007 05:41 PM |
| Compile error: Syntax error: & Else without HELP |
Corey |
VB How-To |
2 |
April 21st, 2006 03:25 PM |
|
 |