Solved

problem to upadte foxpro table with VFPOLEDB VB datat type mismatch

Posted on 2011-03-11
4
1,169 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 41

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 41

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 41

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change Format on Data when exporting to Excel 4 32
ASP.NET 5 Templates 2 78
I need help converting a bitmap to an image in VB.Net 1 32
C# Gridview 1 28
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

806 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