Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server ASP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 20th, 2004, 10:58 AM
Registered User
 
Join Date: Oct 2004
Location: Houston, TX, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL query from input form

I have a form with 2 text boxes for DATE entry that I want to pass into a SQL query. I keep getting error message:
Database Results Wizard Error
Description: Syntax error converting datetime from character string.
Number: -2147217913 (0x80040E07)
Source: Microsoft OLE DB Provider for SQL Server

My two text boxes are called startdate and enddate, and post into my .asp page with this SQL query.

select dispatch.dispatch,dispatch.recdate,dispatch.comple te,dispatch.invoice,salesled.prod,salesled.price,s alesled.tax1 from (salesled inner join sales on salesled.invoice=sales.invoice)inner join dispatch on dispatch.dispatch=sales.dispatch where Sales.invdate between '& Request.form(startdate)&' and '& Request.form(enddate)&' and salesled.prod <> 'HIST' order by dispatch.dispatch

I have tried putting "" around startdate and enddate.

Josh Lindsay
Reply With Quote
  #2 (permalink)  
Old October 20th, 2004, 11:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

In what format are you passing the date values to the Query?

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #3 (permalink)  
Old October 20th, 2004, 11:50 AM
Registered User
 
Join Date: Oct 2004
Location: Houston, TX, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am putting this in the text box.....
3/20/2004

When I hardcode that into the sql query it works fine.

Josh Lindsay
Reply With Quote
  #4 (permalink)  
Old October 20th, 2004, 12:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Okay, this is how it should be.
Code:
strSQL = "select dispatch.dispatch,dispatch.recdate,dispatch.complete,dispatch.invoice,
salesled.prod,salesled.price,salesled.tax1 from (salesled inner join 
sales on salesled.invoice=sales.invoice)inner join dispatch on 
dispatch.dispatch=sales.dispatch where Sales.invdate between '" & 
Request.form(startdate) & "' and '" & Request.form(enddate)& "' and 
salesled.prod <> 'HIST' order by dispatch.dispatch"
Response.write strSQL
Response.End
Just after this line do a response.write and see how the query is constructed and compare with the one that worked fine, when you hard coded. You can even copy paste the resulting Query on SQL Query analyser and see if that returns any error still.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #5 (permalink)  
Old October 20th, 2004, 12:13 PM
Registered User
 
Join Date: Oct 2004
Location: Houston, TX, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

still getting the same error message. Is there anything else you can think of?

Josh Lindsay
Reply With Quote
  #6 (permalink)  
Old October 20th, 2004, 12:25 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you post the SQL statement that resulted from the RESPONSE.WRITE? Let me take a look at it.

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
  #7 (permalink)  
Old October 21st, 2004, 12:54 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Cochin, Kerala, India.
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

I think you need to extract the date, month and year parts of the value in textbox and pass it to query in the format MM/DD/YYYY. What comes from the textbox may not be in this format now.

IMO, a combination of 3 combo boxes is best for taking a date input.
Reply With Quote
  #8 (permalink)  
Old October 21st, 2004, 09:24 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Josh Lindsay,

Has that issue been resolved?

Cheers!

_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pass-through query with input parmeter jimmy Access 4 February 8th, 2018 10:21 AM
Oracle connection-passing input to query!! thottufj Pro Visual Basic 2005 1 October 18th, 2007 03:21 PM
Update table using SQL query from form pater53 Access VBA 4 January 24th, 2007 11:24 AM
Form Input, Parameters, Report Based on Query DavidWE Access VBA 2 November 6th, 2006 10:36 AM
passing input to a query mirage Access 3 October 23rd, 2003 08:43 AM



All times are GMT -4. The time now is 12:17 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.