Solved

problem to upadte foxpro table with VFPOLEDB VB datat type mismatch

Posted on 2011-03-11
4
1,170 Views
Last Modified: 2012-05-11
Hi im trying to update foxpro table but when I update datetime filed I get data type mismatch.

 Dim strSelect As String = "INSERT INTO expense (Expno, Editpc, Edituser, Edittime) VALUES (" & ConfoRequest.FSExpNo & ", """ & ConfoRequest.FSPC & _
             """,""" & ConfoRequest.FSCreatedBy & """,""" & Now & """)"

Open in new window


0
Comment
Question by:gowerman
  • 3
4 Comments
 
LVL 42

Expert Comment

by:pcelba
ID: 35107771
Correct nonambiguous datetime format in VFP is:

{^YYYY.MM.DD HH:MM:SS}

You could also try ambiguous format:

...   & """,""{" & Now & "}"")"

which can be refused by VFP (this depends on SET DATE and SET STRICTDATE settings).

Additional options are 1) parameter in INSERT command or 2) DATETIME function in INSERT.

DATETIME has 6 parameters and its creation as a string will look ugly, so the parameter seems to be the easiest option.
0
 
LVL 42

Expert Comment

by:pcelba
ID: 35107814
Hmm, some features of VB.NET are not bad...

Now.ToString("{^yyyy/mm/dd hh:mm:ss}")   is exactly what you need.

0
 

Author Comment

by:gowerman
ID: 35107926

If i try & """,""{" & Now & "}"")"  then error is to many arguments and
strSelect = "INSERT INTO expense (Expno, Editpc, Edituser, Edittime) VALUES (1110620, "ROB","xxx","","{11/03/2011 13:17:08}")"

when I try Now.ToString("{^yyyy/mm/dd hh:mm:ss}") then I have same error and my string looks like that

strSelect = "INSERT INTO expense (Expno, Editpc, Edituser, Edittime) VALUES (1110620, "ROB","xxx","{^2011/19/11 01:19:34}")"

when I change "/" to "."  then same data type mismatch

0
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 35107959
My fault. Double quotes must be removed:

...   & """, " & Now.ToString("{^yyyy/mm/dd hh:mm:ss}") & ")"

0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

856 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