Solved

Add Records to VFP nTable from C#

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
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…

856 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