If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Insert into - Syntax error in date in query expression '##'.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-27-04, 13:05
iamjosh iamjosh is offline
Registered User
 
Join Date: Feb 2004
Posts: 19
Insert into - Syntax error in date in query expression '##'.

ADD = "INSERT INTO Permtracker (Address, plan, Community, IntranetPost_date, submit_date, Acct_pu_date, Est_pu_date, Issue_date) Values ('"& Address &"', '"& plan &"', '"& Community &"', #"& IntranetPost_date &"#, #"& submit_date &"#, #"& Acct_pu_date &"#, #"& Est_pu_date &"#, #"& Issue_date &"#)"


Error is:

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

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


That's the error I get when one of the date fields is blank, Anywya to write things different with out writing a huge if statment checking for the million of possbile combos?

Thanks,
-josh
Reply With Quote
  #2 (permalink)  
Old 02-27-04, 16:45
iamjosh iamjosh is offline
Registered User
 
Join Date: Feb 2004
Posts: 19
bump.

Anything?
Reply With Quote
  #3 (permalink)  
Old 02-27-04, 20:45
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
In your case, you need to check if the date is blank.
Reply With Quote
  #4 (permalink)  
Old 02-27-04, 21:14
iamjosh iamjosh is offline
Registered User
 
Join Date: Feb 2004
Posts: 19
Any other way to do this without a zillion if, else, if else, if, else ?

Thanks,
-josh
Reply With Quote
  #5 (permalink)  
Old 02-27-04, 21:31
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
There are five fields with date datatype. Since the blank is allowed, I guess these fields in table can be NULL or '', right?
Reply With Quote
  #6 (permalink)  
Old 02-27-04, 21:44
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
<%
Dim SQL1, SQL2, SQL
SQL1 = "INSERT INTO Permtracker (Address, plan, Community"
SQL2 = "Values('" & Address & "', '" & plan & "', '" & Community & "'"

If Not IsEmpty(IntranetPost_date) AND Trim(IntranetPost_date) <> "" Then
SQL1 = SQL1 & ", IntranetPost_date"
SQL2 = SQL2 & ", #" & IntranetPost_date & "#"
End If

If Not IsEmpty(submit_date) AND Trim(submit_date) <> "" Then
SQL1 = SQL1 & ", submit_date"
SQL2 = SQL2 & ", #" & submit_date & "#"
End If

If Not IsEmpty(Acct_pu_date) AND Trim(Acct_pu_date) <> "" Then
SQL1 = SQL1 & ", Acct_pu_date"
SQL2 = SQL2 & ", #" & Acct_pu_date & "#"
End If

If Not IsEmpty(Est_pu_date) AND Trim(Est_pu_date) <> "" Then
SQL1 = SQL1 & ", Est_pu_date"
SQL2 = SQL2 & ", #" & Est_pu_date & "#"
End If

If Not IsEmpty(Issue_date) AND Trim(Issue_date) <> "" Then
SQL1 = SQL1 & ", Issue_date"
SQL2 = SQL2 & ", #" & Issue_date & "#"
End If

SQL = SQL1 & SQL2 & ")"
%>
Reply With Quote
  #7 (permalink)  
Old 02-27-04, 22:02
iamjosh iamjosh is offline
Registered User
 
Join Date: Feb 2004
Posts: 19
fixed one minor thing..on the 4th line (sql2

SQL1 = "INSERT INTO Permtracker (Address, plan, Community"
SQL2 = "Values('" & Address & "', '" & plan & "', '" & Community & "'"

Added

SQL2 = ") Values('" & Address & "', '" & plan & "', '" & Community & "'"


All in all though that code is a lot cleaner and I like it thanks.

-josh
Reply With Quote
  #8 (permalink)  
Old 02-28-04, 21:18
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
You are right. I forgot to put ") " at the beginning of SQL2.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On