Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connecting to VFP tables
Message
From
28/02/2008 20:43:08
 
 
To
28/02/2008 17:28:20
Dave Nantais
Light speed database solutions
Ontario, Canada
General information
Forum:
ASP.NET
Category:
Databases
Miscellaneous
Thread ID:
01297514
Message ID:
01297641
Views:
30
Hi Dave,

Your sample code looks a bit familiar ... I frequently use "select * from bob" in my examples. You've also left SqlCommand when you meant to use OleDbCommand. But, nevermind .... <g>

I haven't messed with fox data lately in .NET, but are you sure the tables needs a primary key? That may only be if you're using things like the command builder perhaps?

~~Bonnie




>it can be done, however, you need to have a primary key field in each foxpro 2.x table that you'd like to update.
>
>make sure all the free Fox 2.x tables are in c:\mydatadirectory\
>
>
>public void UpdateMyData(DataSet ds)
>{
> // I wouldn't actually hard-code the connection string here, it should be in your config settings
> string TestConnection =
>"Provider=vfpoledb.1;Data Source=C:\MyDataDirectory\;Collating Sequence=general";
>
> SqlCommand sc = new SqlCommand();
> sc.Connection = new SqlConnection(TestConnection);
> sc.Connection.Open();
> foreach (DataRow Row in ds.Tables[0].Rows)
> {
> switch (Row.RowState)
> {
> case DataRowState.Added :
> sc.CommandText = "Insert into bob (xyz, abc) VALUES ( @xyz, @abc )";
> sc.Parameters.Clear();
> sc.Parameters.Add("@xyz", Row["xyz"]);
> sc.Parameters.Add("@abc", Row["abc"]);
> sc.ExecuteNonQuery();
> break;
>
> // Do the same for DataRowState Deleted and Modified
> case DataRowState.Deleted :
> break;
> case DataRowState.Modified :
> break;
> }
> }
> sc.Connection.Close();
>}
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform