Solved

Add Records to VFP nTable from C#

Posted on 2013-05-13
3
968 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
3 Comments
 
LVL 74

Accepted Solution

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

13 Experts available now in Live!

Get 1:1 Help Now