Vb 6 Update Stmt Into Oracle Db
My application is in VB 6 and am using an Oracle database behind it. I am trying to run the following sql update statement using variables in vb. I keep getting an error when it tries to insert the date (finish = '" & aTask.Finish & ). If I take out the part w/ the dates, my database record updates fine. I've tried using the to_date function and several other methods but can't seem to fix it. Any ideas? And for example, when I run debug and mouse over the aTask.Finish variable the date format that shows is 5/25/2007 5:00:00 PM
m_Connection.Execute ("update tblprojectschedule set TaskName='" & aTask.Name & "'" & ", ComplePercent='" & aTask.PercentComplete & "'" & " " & ",finish = '" & aTask.Finish & "', where ctwprojno = '" & IndivProjectFileName & "'" & " " & "And relno = '" & aTask.Text9 & "'")
Re: Vb 6 Update Stmt Into Oracle Db
Welcome to VBForums :wave:
Thread moved to Database Development forum
How you put dates/times into SQL statements depends on the database system, and while I don't use Oracle myself, I have replicated what is contained in the help files in the article How do I use values (numbers, strings, dates) in SQL statements? from our Database Development FAQs/Tutorials (at the top of this forum)
Hopefully that will tell you enough to get it working. :)
Re: Vb 6 Update Stmt Into Oracle Db
All Oracle dataes going to the databse should be in the Oracle expected format (DD-MON-YY as a string) So to place todays date (11/20/2007) into Oracle (without using any conversion functions) it should be sent as '20-Nov-07'. The other way is to use the To_Date() funtion of Oracle like this:
To_Date('11/20/2007','mm/dd/yyyy').
All database engines require their dates in a specific format and passed a certian way.
Re: Vb 6 Update Stmt Into Oracle Db
Or use Oracle's default date format is DD-MMM-YYYY:
..., finish = '" & Format(your_date_value, "dd-mmm-yyyy") & "',"...