Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
C# 2005 updating VFP data
Message
From
09/10/2006 07:53:46
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01160448
Message ID:
01160494
Views:
8
>I am trying to update a VFP table with C# using code like the following:
>
>OleDbCommand olecmd = new OleDbCommand(strcmd, oleconn);
>olecmd.ExecuteNonQuery();
>
>I do get an exception raised with 'Feature not Available' so my question is: is there anyway to update VFP data using C# or any .NET language?
>
>Your response is greatly appreciated.

Bob,
It's returning an error message "Feature is not available". That means your strCmd has something unsupported by VFPOLEDB driver in it (or implicitly invoked stored procedure have some unsupported function/command). Otherwise insert/update/select/delete via VFPOLEDB is straight forward.
PS: I don't see any parameters in your sample. Where are they? Might be no parameters. Hopefully you didn't hardcode them into strCmd. A typical update looks like this:
OleDbCommand cmdUpdate = cn.CreateCommand();
cmdUpdate.CommandText = "update myTable set myField1 = ?, myField2 = ? where myId = ?";

OleDbParameter p1  = new OleDbParameter("id",OleDbType.Integer);
OleDbParameter p2  = new OleDbParameter("myField1",OleDbType.Integer);
OleDbParameter p3  = new OleDbParameter("myField2",OleDbType.Char);

cmdUpdate.Parameters.Add(p2); // note that add order matches parameter position in command
cmdUpdate.Parameters.Add(p3);
cmdUpdate.Parameters.Add(p1);

id.Value      = 1;
myField1.Value = 2;
myField2.Value = "Hello";
cmdUpdate.ExecuteNonQuery();
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform