MS Access 更新查询问题

发布于 2024-08-18 09:14:57 字数 2100 浏览 1 评论 0原文

我正在尝试使用此功能从 c# ado.net 更新我的表。我正在使用 access db 中的更新过程存储过程。在 MS Access 端一切工作正常。提供参数来访问及其更新良好。但是当我尝试此操作时c# ado.net 端没有给出任何错误,但它没有更新。我有很多工作存储过程,就像这样。

这是我的 ado.net 侧代码;

 public void TakipsizlikGuncelleYeni(int kararNo, int kararYil, int yeniSorNo, int yeniSorYil,int durum)
  {
      con.Open();
      cmd = new OleDbCommand("sp_NewUpdate", con);
      cmd.CommandType = CommandType.StoredProcedure;
      OleDbParameter prmDurum = new OleDbParameter();
      prmDurum.ParameterName = "@durum";
      prmDurum.OleDbType = OleDbType.Integer;
      prmDurum.Value = durum;
      OleDbParameter prmTakipsizlikNo = new OleDbParameter();
      prmTakipsizlikNo.ParameterName = "@takipsizlikno";
      prmTakipsizlikNo.OleDbType = OleDbType.Integer;
      prmTakipsizlikNo.Value = kararNo;
      OleDbParameter prmTakipsizlikYil = new OleDbParameter();
      prmTakipsizlikYil.ParameterName = "@takipsizlikyil";
      prmTakipsizlikYil.OleDbType = OleDbType.Integer;
      prmTakipsizlikYil.Value = kararYil;
      OleDbParameter prmYeniSorYil = new OleDbParameter();
      prmYeniSorYil.ParameterName = "@yenisoryil";
      prmYeniSorYil.OleDbType = OleDbType.Integer;
      prmYeniSorYil.Value = yeniSorYil;
      OleDbParameter prmYeniSorNo = new OleDbParameter();
      prmYeniSorNo.ParameterName = "@yenisorno";
      prmYeniSorNo.OleDbType = OleDbType.Integer;
      prmYeniSorNo.Value = yeniSorNo;
      cmd.Parameters.Add(prmDurum);
      cmd.Parameters.Add(prmTakipsizlikNo);
      cmd.Parameters.Add(prmTakipsizlikYil);
      cmd.Parameters.Add(prmYeniSorNo);
      cmd.Parameters.Add(prmYeniSorYil);



      int sonuc = cmd.ExecuteNonQuery();
      if (sonuc > 0)
          MessageBox.Show("İşlem Tamamlandı", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
      con.Close();
  }

和我的访问端存储的程序;

UPDATE Takipsizlik SET Durum = [@durum], YeniSorusturmaNo = [@yenisorno], YeniSorYil = [@yenisoryil]
WHERE (((TakipsizlikNo)=[@takipsizlikno]) AND ((TakipsizlikYil)=[@takipsizlikyil]));

我看不到任何错误?为什么此代码不更新我的表?

I am trying update my table from c# ado.net with this function.I am using for update process stored prosedure in access db.Everything working fine in MS Access side.Giving parameters to access and its update well.But when i tried this in c# ado.net side not giving any error but its not updating.I have got so many working stored procedure, like this.

Here my ado.net side codes;

 public void TakipsizlikGuncelleYeni(int kararNo, int kararYil, int yeniSorNo, int yeniSorYil,int durum)
  {
      con.Open();
      cmd = new OleDbCommand("sp_NewUpdate", con);
      cmd.CommandType = CommandType.StoredProcedure;
      OleDbParameter prmDurum = new OleDbParameter();
      prmDurum.ParameterName = "@durum";
      prmDurum.OleDbType = OleDbType.Integer;
      prmDurum.Value = durum;
      OleDbParameter prmTakipsizlikNo = new OleDbParameter();
      prmTakipsizlikNo.ParameterName = "@takipsizlikno";
      prmTakipsizlikNo.OleDbType = OleDbType.Integer;
      prmTakipsizlikNo.Value = kararNo;
      OleDbParameter prmTakipsizlikYil = new OleDbParameter();
      prmTakipsizlikYil.ParameterName = "@takipsizlikyil";
      prmTakipsizlikYil.OleDbType = OleDbType.Integer;
      prmTakipsizlikYil.Value = kararYil;
      OleDbParameter prmYeniSorYil = new OleDbParameter();
      prmYeniSorYil.ParameterName = "@yenisoryil";
      prmYeniSorYil.OleDbType = OleDbType.Integer;
      prmYeniSorYil.Value = yeniSorYil;
      OleDbParameter prmYeniSorNo = new OleDbParameter();
      prmYeniSorNo.ParameterName = "@yenisorno";
      prmYeniSorNo.OleDbType = OleDbType.Integer;
      prmYeniSorNo.Value = yeniSorNo;
      cmd.Parameters.Add(prmDurum);
      cmd.Parameters.Add(prmTakipsizlikNo);
      cmd.Parameters.Add(prmTakipsizlikYil);
      cmd.Parameters.Add(prmYeniSorNo);
      cmd.Parameters.Add(prmYeniSorYil);



      int sonuc = cmd.ExecuteNonQuery();
      if (sonuc > 0)
          MessageBox.Show("İşlem Tamamlandı", "Kayıt", MessageBoxButtons.OK, MessageBoxIcon.Information);
      con.Close();
  }

and my Access Side stored prosedure ;

UPDATE Takipsizlik SET Durum = [@durum], YeniSorusturmaNo = [@yenisorno], YeniSorYil = [@yenisoryil]
WHERE (((TakipsizlikNo)=[@takipsizlikno]) AND ((TakipsizlikYil)=[@takipsizlikyil]));

i could not see any error ? Why this codes not update my table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不…忘初心 2024-08-25 09:14:57

Access 接收的参数为“?” - 它们没有命名 - 只需使用“问号”占位符。

它们必须按照它们在查询中出现的确切顺序传递。

这是 OLEDB 的限制。

https://web. archive.org/web/20210927192856/http://www.4guysfromrolla.com/webtech/092601-1.2.shtml

Access receives parameters as "?" - they are not named - just use "Question mark" placeholder.

They must be passed in exact order they appear in the query.

This is a limitation of OLEDB.

https://web.archive.org/web/20210927192856/http://www.4guysfromrolla.com/webtech/092601-1.2.shtml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文