1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| public void RecupererTableIntervention()
{
SqlCeConnection Cnx = null;
SqlCeRemoteDataAccess Rda = null;
SqlCeEngine Engine = null;
string sConnexionLocale = @"Data Source=\My Documents\DistribInfo.sdf";
string sConnexionDistante = "Provider=sqloledb; Data Source=DIST-5B8D87E3A9;Initial Catalog=Distrib";
try
{
if (!File.Exists("/My Documents/DistribInfo.sdf"))
{
Engine = new SqlCeEngine(sConnexionLocale);
Engine.CreateDatabase();
Engine.Dispose();
}
else
{
Cnx = new SqlCeConnection(sConnexionLocale);
Cnx.Open();
SqlCeCommand Cmd = Cnx.CreateCommand();
Cmd.CommandText = "DROP TABLE INTERVENTION";
Cmd.ExecuteNonQuery();
if (Cnx.State != ConnectionState.Closed) Cnx.Close();
}
Rda = new SqlCeRemoteDataAccess();
Rda.InternetLogin = "";
Rda.InternetPassword = "";
Rda.InternetUrl = "http://192.168.0.1/sqlce/sscesa20.dll";
Rda.LocalConnectionString = sConnexionLocale;
Rda.Pull("INTERVENTION",
"Select * from INTERVENTION",
sConnexionDistante,
RdaTrackOption.TrackingOnWithIndexes ,
"ErrorTable");
}
catch (SqlCeException sqlex)
{
foreach(SqlCeError sqlError in sqlex.Errors)
{
MessageBox.Show(sqlError.Message + " " +sqlError.Source + " " +
sqlError.NativeError + " " + sqlError.HResult);
MessageBox.Show(sqlError.Message,"Erreur");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,"Erreur");
}
finally
{
Rda.Dispose();
}
} |
Partager