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();
}
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only