Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Connecting to VFP tables
Message
De
28/02/2008 17:28:20
Dave Nantais
Light speed database solutions
Ontario, Canada
 
 
À
28/02/2008 14:14:46
Rex Mahel
Realm Software, Llc
Ohio, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Divers
Thread ID:
01297514
Message ID:
01297591
Vues:
26
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();
}
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform