Solved

Insert Date into Informix Error

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

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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now