Insert Date into Informix Error

Posted on 2006-11-03
Last Modified: 2008-01-09
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?  

Question by:schealth
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
LVL 26

Accepted Solution

EDDYKT earned 250 total points
ID: 17866849


Author Comment

ID: 17866901
Tried it, but comes back with same message.  Message being:
E42000: (-201) A syntax error has occured.
LVL 20

Expert Comment

ID: 17867254
Have you tried
INSERT INTO mytest (bdate) VALUES (" & DATE (fSDAT) & ")"
Industry Leaders: 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!


Author Comment

ID: 17867534
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.

LVL 20

Assisted Solution

hes earned 250 total points
ID: 17867627
Guessing but

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

added a single quote before and after the variable and using VB date conversion

Author Comment

ID: 17867708
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
LVL 26

Expert Comment

ID: 17868922

Author Comment

ID: 17885513
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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question