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
| var query = "UPDATE tblLR " +
"SET Location = @location " +
", SortedLocation = @sortedLocation" +
", Latitude = @latitude" +
", Longitude = @longitude " +
" WHERE IDLR = @idLr";
var dBcon = new OleDbConnection(Legacy.ConString);
var cmd = new OleDbCommand(query, dBcon);
cmd.Parameters.Add("@location", OleDbType.VarChar).Value = topLegacy.Location.Replace("'", "''");
cmd.Parameters.Add("@sortedLocation", OleDbType.VarChar).Value = topLegacy.Location.Replace("'", "''");
cmd.Parameters.Add("@shortName", OleDbType.VarChar).Value = topLegacy.ShortName.Replace("'", "''");
cmd.Parameters.Add("@latitude", OleDbType.Double).Value = topLegacy.Latitude;
cmd.Parameters.Add("@longitude", OleDbType.Double).Value = topLegacy.Longitude;
cmd.Parameters.Add("@idLr", OleDbType.BigInt).Value = topLegacy.Idlr;
var result = 0;
using (dBcon)
{
try
{
dBcon.Open();
result = cmd.ExecuteNonQuery();
if (result <= 0)
{
string msg = "Erreur dans MettreAJourLegacy avec comme arguments: " +
"\n topLegacy = " + topLegacy.Idlr + " " + topLegacy.ToString() +
"\n topGeoDB = " + topGeoDb.ToString();
MessageBox.Show(msg, "Erreur fatale dans la méthode MettreAJourLegacy()", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
return result <= 0 ? false : true;
}
catch (OleDbException ex)
{
string msg = ex.Message + "\n Erreur dans MettreAJourLegacy avec comme arguments: " +
"\n topLegacy = " + topLegacy.Idlr + " " + topLegacy.ToString() +
"\n topGeoDB = " + topGeoDb.ToString();
// Program.ReportCrash(ex, msg);
// ToponymeNonTraite.ListeToponymesNonTraites.Add(topLegacy);
MessageBox.Show(msg, "Erreur fatale dans la méthode MettreAJourLegacy()", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return false;
}
} |
Partager