Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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
 
Old December 9th, 2003, 06:00 PM
Registered User
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default forms and embedded sql

Hello all. I'm collecting start and end dates from text boxes (format mm/dd/yyyy) as criteria for a query. I set the form names equal to variables like 'string1' and 'string2', but when I try to SELECT * FROM table WHERE date BETWEEN string1 and string2, I am told that I have a data type mismatch. You cannot declare a data type when you dim a variable in asp, correct? Please help if you know of some way around this. Thanks.

 
Old December 10th, 2003, 02:00 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem is not to do with ASP datatypes. When you use an SQL string, you are sending a literal string of text to the *database engine* for processing, and the SQL string needs to be valid, so that it can be parsed by the database engine.

For example, a date field, in Access (you don't mentioned what database you are using) typically needs to be delimited as:

SELECT field1 FROM myTable WHERE dateField BETWEEN #1/1/2003# AND #31/1/2003#

(notice the # marks). SQL Server uses ' for dates.

Secondly, the date needs to be in a format that can be intepreted by the database as a valid date. I would strongly recommend formatting all dates in ISO-style format: yyyy/mm/dd so that the database isn't confused as to what date you mean.

Cheers
Ken


Microsoft MVP - Windows Server (IIS)
www.adOpenStatic.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded SQL in Visual C++ mmkazemi Visual C++ 1 February 28th, 2007 01:54 AM
How to Create SQL Forms brookhou VB Components 0 March 31st, 2006 12:20 AM
pl/sql printing with oracle forms 4.5 drdede SQL Language 0 April 9th, 2004 04:18 AM
Embedded gifs and forms fixitman Access 4 October 16th, 2003 12:47 AM
forms authentication with sql server 2000 Lee8mm ASP.NET 1.0 and 1.1 Professional 0 September 26th, 2003 08:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.