MS Access 更新查询问题
我正在尝试使用此功能从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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