Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using NOW() in INSERT statement

Status
Not open for further replies.

cwolgamott

Programmer
May 29, 2002
69
US
Hello. :) I am building an asp page where I am trying to insert values into a database table. I believe that I may be having difficulty inserting NOW() into a field. I was wondering if that is how I should be inserting the current date and time into a field. Secondly, I am getting the following error:

Microsoft OLE DB Provider for SQL Server (0x80040E14)
Incorrect syntax near the keyword 'VALUES'.

That error message is coming from the following code:

SQL = " INSERT INTO CaseInfo (CaseInfo.casenum, CaseInfo.caller, CaseInfo.subject, CaseInfo.description, CaseInfo.openedby, CaseInfo.dateopened, CaseInfo.daterequested, CaseInfo.dateneeded, CaseInfo.dateestimated, CaseInfo.iscompleted, CaseInfo.respondedto, CaseInfo.percentcomplete, CaseInfo.status "
SQL = SQL + "VALUES (" + CStr(newCaseNumber) + ", " + "'" + inputFullName + "', " + "'" + Request("subject") + "', " + "'" + Request("description") + "', " + "'" + "INTRANET" + "', " + "NOW()" + ", " + "'" + CStr(Request("date1")) + "', " + "'" + CStr(Request("date1")) + "', " + "NOW()" + ", " + "'" + "N" + "', " + "'" + "N" + "', " + "0" + ", " + "'" + "NOT STARTED" + "')"
conn1.Execute(SQL)

I would greatly appreciate any suggestions. :) Thank you. :)
 
1st you are missing the ")" in the first sql chunk.

2nd you can use the GETDATE() from sql server I am not sure that you gain anything, but if your db and iis are on diff boxes you could potentially have problems if the times on the servers go out of sync.

hth
 
Thank you so much for your reply. :) I greatly appreciate it. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top