Solved

Insert Date into Informix Error

Posted on 2006-11-03
8
1,991 Views
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?  

Mitch
0
Comment
Question by:schealth
  • 4
  • 2
  • 2
8 Comments
 
LVL 26

Accepted Solution

by:
EDDYKT earned 250 total points
ID: 17866849
try

("#12/23/2006#")
0
 

Author Comment

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

Expert Comment

by:hes
ID: 17867254
Have you tried
INSERT INTO mytest (bdate) VALUES (" & DATE (fSDAT) & ")"
0
Independent Software Vendors: 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

by:schealth
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.

Mitch
0
 
LVL 20

Assisted Solution

by:hes
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
0
 

Author Comment

by:schealth
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
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 17868922
0
 

Author Comment

by:schealth
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.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…

756 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