Solved

problem to upadte foxpro table with VFPOLEDB VB datat type mismatch

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 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

16 Experts available now in Live!

Get 1:1 Help Now