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
  • 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) & ")"
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.


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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Computer crashes, following error message in event manager 5 199
vbModal 12 52
Create Files based on Cell Values in a Range in Excel 12 39
Send outlook email from VBS Script 2 30
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

778 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