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 > Inserting date into an Oracle table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-05-05, 03:27
rajthampi rajthampi is offline
Registered User
 
Join Date: Feb 2004
Location: Kuwait
Posts: 38
Question Inserting date into an Oracle table

Greetings

I wonder how I can insert date values into an Oracle table through ASP. Please refer the script provided and suggest me what would be the best solution
Code:
<% Option Explicit %>
<% Session.LCID=2057%>
<!--#include File="Common.asp"-->
<%
	Dim adoCon				'Holds ADODB Connection
	Dim strSQL				'Holds query string for the Recordset
	Dim lrqno				'Holds the last service request number
	Dim udate				'Holds todays date
	Dim CompDescription
	udate = "'" & Date & "'"
	
	CompDescription = REPLACE(Request.Form("reqdes"),"'","~")
	
	Set adoCon = Server.CreateObject("ADODB.Connection")
	adoCon.Open = "DSN=OraKMD;UID=kmd;PWD=kmd;"
	
	strSQL = "select NVL(max(SRVC_UNIQUE_ID)+1,1) from USR_SRVC_RQTS"
	lrqno = adoCon.Execute(strSQL).Fields(0).value
	
	strSQL = "Insert into USR_SRVC_RQTS"_
			& "(PC_USER_ID,SRVC_REQ_DESCR,SRVC_REQ_DATE,SRVC_UNIQUE_ID)"_
			& "Values("_
			& "'"& Request.Form("usercode") & "'"&","_
			& "'"&CompDescription&"'" & ","_
			& to_date('2/2/2005','MM-DD-YYY') & ","_
			& lrqno & ")"
	adoCon.Execute(strSQL)
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
Successfully updated!
<% Response.Redirect("RequestService.asp?userid="&Request.Form("usercode")) %>
</body>
</html>
<% adoCon.Close %>
When I run this script explorer returns me the following error:
Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/UpdateServiceRequest.asp, line 25, column 10
& to_date('2/2/2005','MM-DD-YYY')


Any ideas? I am lost by the middle of a project just because I cannot insert date fields and rolling back to MS SQL means a nightmare to me.

Thanks in advance
__________________
If it is a door, It will open.
Reply With Quote
  #2 (permalink)  
Old 12-05-05, 04:03
rajthampi rajthampi is offline
Registered User
 
Join Date: Feb 2004
Location: Kuwait
Posts: 38
Thumbs up Okay, I managed it

I managed to do it somehow and it works. I re-structured the Query string as follows:

Code:
strSQL = "Insert into USR_SRVC_RQTS"_
			& "(PC_USER_ID,SRVC_REQ_DESCR,SRVC_REQ_DATE,SRVC_UNIQUE_ID)"_
			& "Values("_
			& "'"& Request.Form("usercode") & "'"&","_
			& "'"&CompDescription&"'" & ","_
			& "To_Date(" & udate & "," & "'" & "MM-DD-YYYY" & "'" & ")" & ","_
			& lrqno & ")"
I hope this might help somebody out there seeking help with inserting date values into an Oracle table through ASP.

Thanks
__________________
If it is a door, It will open.
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