Current location: Hot Scripts Forums » Programming Languages » ASP » Problem in All Records Displaying


Problem in All Records Displaying

Reply
  #1 (permalink)  
Old 12-28-04, 01:02 AM
ishaqani ishaqani is offline
Newbie Coder
 
Join Date: May 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Problem in All Records Displaying

I have 4 form fields, for Multiple Combination Query. I m getting the below error when i run the query without any values in date range form (Blank Form). or when i run the query using only Impname or Agname, without Date range.

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC Microsoft Access Driver] Syntax error in date in query expression 'IGMDAT BETWEEN ## AND ##'.


Below is the Query Code:

<%
varField3 = Replace(Request("data3"), "'", "''")
Qdate11 = Replace(Request("begin"), "'", "")
Qdate22 = Replace(Request("end"), "'", "")

SQLstr = "SELECT * FROM 652 WHERE IGMDAT BETWEEN #" & Qdate11 & "# AND #" & Qdate22 & "#"
AndString = ""

If varField3 <> "" Then
AndString = AndString & " AND SAGENT LIKE '%" & varField3 & "%'"
End If

If Qdate11 <> "" Then
AndString = AndString & " AND IGMDAT >= #" & Qdate11 & "#"
End If

If Qdate22 <> "" Then
AndString = AndString & " AND IGMDAT <= #" & Qdate22 & "#"
End If

SQLstr = SQLstr & AndString
%>


Plz solve my problem.
Reply With Quote
  #2 (permalink)  
Old 12-28-04, 06:44 AM
chirag's Avatar
chirag chirag is offline
Newbie Coder
 
Join Date: May 2004
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb

Hi there,

You need to change your code like this if you are going to allow null dates in input ...

<%
varField3 = Replace(Request("data3"), "'", "''")
Qdate11 = Replace(Request("begin"), "'", "")
Qdate22 = Replace(Request("end"), "'", "")

if Qdate11 <> "" and Qdate22 <> "" then
SQLstr = "SELECT * FROM 652 WHERE IGMDAT BETWEEN #" & Qdate11 & "#
AND #" & Qdate22 & "#"
AndString = " And "
else
SQLstr = "SELECT * FROM 652 "
AndString = " where "
end if

If varField3 <> "" Then
'''''''note: And is removed from here.....
AndString = AndString & " SAGENT LIKE '%" & varField3 & "%'"
End If

If Qdate11 <> "" Then
AndString = AndString & " AND IGMDAT >= #" & Qdate11 & "#"
End If

If Qdate22 <> "" Then
AndString = AndString & " AND IGMDAT <= #" & Qdate22 & "#"
End If

SQLstr = SQLstr & AndString
%>

Last edited by chirag; 12-28-04 at 06:53 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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 On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
having problem in retrieving data n displaying data from database mathfxr JavaScript 1 11-23-04 12:42 AM
help! urgent.. how to select next 50 records? angela ASP 3 04-24-04 12:58 PM
Displaying selected records DanGB ASP 2 02-22-04 10:31 AM
Problem in Deleting records from Access skchakri ASP 1 09-20-03 12:59 AM
displaying all duplicate records in my table. dsumpter PHP 6 09-02-03 10:54 AM


All times are GMT -5. The time now is 03:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.