Solved

Add Records to VFP nTable from C#

Posted on 2013-05-13
3
982 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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

756 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