我有一个使用.NET C#MVC和Access DB的应用程序。它可以在我的本地计算机上运行,但是当我在服务器上上传应用程序时出现问题。我在SQL中使用的所有SELECT均有效,但UPDATE无效,并且出现以下消息:“操作必须使用可更新的查询。(错误3073)”。谢谢!
UPDATE语句:
try
{
BDD_Linker instance = BDD_Linker.Instance;
Requete_Ecriture sql = new RUpdate(
"Fiche_Impact",
"Date_Mise_a_jour = #10/09/1999#",
"[ID] = 64");
instance.ExecuterRequete(sql);
}
catch (MyException ex)
{
return new HtmlString(ex.Affiche()); **//The error "Operation must use an updatable query. (Error 3073)" is here**
}
RUpdate类:
public class RUpdate : Requete_Ecriture
{
public string Update { get; set; }
public string Set { get; set; }
public string Where { get; set; }
public RUpdate(string update, string set, string where)
{
this.Update = update;
this.Set = set;
this.Where = where;
}
public override string getTable() { return Update; }
public override string getRequete()
{
string s = "UPDATE " + Update + " SET " + Set;
if (!string.IsNullOrEmpty(Where))
s += " WHERE " + Where;
return s;
}
}
ExecuterRequete函数:
OleDbConnection connect = BDD_Connect(sql_requete.getTable());
try
{
OleDbCommand command = new OleDbCommand(Traducteur.Instance.traduction(sql_requete.getRequete()), connect);
int i = command.ExecuteNonQuery();
connect.Close();
return i;
}
catch (Exception ex)
{
connect.Close();
throw (new MyException("BDD_Excution_Ecriture", "Erreur dans l'execution de la requete", ex.Message));
}