[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add Records to VFP nTable from C#

Posted on 2013-05-13
3
Medium Priority
?
999 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 1000 total points
ID: 39162812
You have a stray semi-colon in your query.
0
 
LVL 43

Assisted Solution

by:pcelba
pcelba earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

649 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