Solved

Add Records to VFP nTable from C#

Posted on 2013-05-13
3
986 Views
Last Modified: 2013-05-13
I have what I thought was a simple task. I need to write a program that will pluck selected records from a SQL Express database and insert them into a VFP table. Through testing, I can query the VFP table with no trouble. I was able to add the contents to a DataTable just to make sure I have access through VfpOleDb.

When I try to insert anything into a table, I get a syntax error. I can insert records in Fox with no problem just using a standard insert statement. I'm totally baffled as to why I cannot do this from C#. Here is my simple code:

string AcmeConnStr = GetConnectionString("acmeconn.txt"); 
OleDbConnection AcmeConnection = new OleDbConnection(AcmeConnStr);
AcmeConnection.Open();
            
string SampleInsert = "INSERT INTO cust(custid); Values( ? )";
OleDbCommand cmd3 = new OleDbCommand( SampleInsert, AcmeConnection);
cmd3.Parameters.Add(new OleDbParameter("?", "0000007436"));
            
cmd3.ExecuteNonQuery()

Open in new window


I'm at its end so I thought maybe someone has had to do this and can help me out.
0
Comment
Question by:jczander
[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 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 39162812
You have a stray semi-colon in your query.
0
 
LVL 42

Assisted Solution

by:pcelba
pcelba earned 250 total points
ID: 39162815
It seems there is an extra semicolon in the command line:

string SampleInsert = "INSERT INTO cust(custid); Values( ? )";

try:
string SampleInsert = "INSERT INTO cust (custid) Values ( ? )";

if it does not help then try the command without parameter to avoid other problems:
string SampleInsert = "INSERT INTO cust (custid) Values ( [0000007436] )";
0
 

Author Closing Comment

by:jczander
ID: 39162936
Oh jeebus! Thanks guys.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Visual FoxPro (short VFP) is a programming language with it’s own IDE and database, ranking somewhat between Access and VB.NET + SQL Server (Express). Product Description: http://msdn.microsoft.com/en-us/vfoxpro/default.aspx (http://msd…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

737 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