Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2057
  • Last Modified:

Insert Date into Informix Error

I am trying to set up a program to take and pass information to an Informix database.  I have the SQL command set up as follows:
INSERT INTO mytest (bdate) VALUES (" & fSDAT & ")"
Where the reulting SQL statement shows as:
INSERT INTO mytest (bdate) VALUES (12/23/2006)
For some reason executing the statement through VB is coming back with a syntax error.  I have also tried
INSERT INTO mytest (bdate) VALUES ("12/23/2006") and
INSERT INTO mytest (bdate) VALUES ('12/23/2006')
the last of which gives me a date string conversion error.  The others just come back as being syntax error.
Does anyone know why this would be happening?  

Mitch
0
schealth
Asked:
schealth
  • 4
  • 2
  • 2
2 Solutions
 
EDDYKTCommented:
try

("#12/23/2006#")
0
 
schealthAuthor Commented:
Tried it, but comes back with same message.  Message being:
E42000: (-201) A syntax error has occured.
0
 
hesCommented:
Have you tried
INSERT INTO mytest (bdate) VALUES (" & DATE (fSDAT) & ")"
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
schealthAuthor Commented:
Ok, I did try it, and I still come up with the same error message.
I tried both INSERT INTO mytest (bdate) VALUES (" & DATE(fSDAT) & ")"
and INSERT INTO mytest (bdate) VALUES ( DATE" & fSDAT & ")"  neither worked.
I have tried the following command in CuteSQL and worked fine, but will not work
coming from VB:
INSERT INTO mytest (bdate) VALUES ('12/23/2006')
Not sure if there is a problem with passing a variable or what the isue is, but char and
numeric values seem to pass fine with the same statement.

Mitch
0
 
hesCommented:
Guessing but

INSERT INTO mytest (bdate) VALUES ('" & CDate (fSDAT) & "')"

added a single quote before and after the variable and using VB date conversion
0
 
schealthAuthor Commented:
I just tried to use CDate conversion and the message it gave me now is that
EIX000: (-1218) String to date conversion error
Without the single quotes the same error as above.
E42000: (-201) A syntax error has occured
0
 
schealthAuthor Commented:
I finially did get this one to work.  For some reason I did have the right statement, however it wanted the date formated as yyyy/mm/dd.  I apreciate all the help and will split the points acordingly.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now