Solved

problem to upadte foxpro table with VFPOLEDB VB datat type mismatch

Posted on 2011-03-11
4
1,172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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