访问2010和C#.net中的查询是否错误 [英] is it wrong query in access 2010 and C#.net

查看:85
本文介绍了访问2010和C#.net中的查询是否错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



错误查询C#.net和Access数据库



Hi all

Is it wrong Query in C#.net and Access database

string _command_up_stat_comm = "
UPDATE Ghesting SET status_pay = ? WHERE (fk_code_m_buyer = ?) AND (date_ghest = ?)";
  OleDbParameter[] pa_sta_gh = new OleDbParameter[3];
  pa_sta_gh[0] = new OleDbParameter("status_pay", OleDbType.Char);
  pa_sta_gh[0].Value = Convert.ToString(U_status_ghest_comm);
  pa_sta_gh[1] = new OleDbParameter("fk_code_m_buyer", OleDbType.Char);
  pa_sta_gh[1].Value = Convert.ToString(code_m_pay_comm);
  pa_sta_gh[2] = new OleDbParameter("date_ghest", OleDbType.Char);
  pa_sta_gh[2].Value = Convert.ToString(date_pay_comm);
  a.Query_Update_command(_command_up_stat_comm, pa_sta_gh);





此代码和查询运行但是没有正确



this code and query run but don't correctly

推荐答案

查询看起来不错。复制并在后端运行它以确认它是否有效。
The query looks good. Copy it and run it at the backend to confirm it works.


如果date_ghest字段是日期数据类型,为什么要将它设置为char?



If date_ghest field is date data type, why do you set it as a char?

pa_sta_gh[2] = new OleDbParameter("date_ghest", OleDbType.Char);





使用正确的日期格式!



我建议使用命名参数:





Use proper date format!

I'd suggest to use named parameters:

PARAMETERS [sta_pay] CHAR, [code_buyer] CHAR, [date_ghest] DATETIME;
UPDATE Ghesting SET status_pay = [sta_pay]
WHERE ((fk_code_m_buyer = [code_buyer]) AND (date_ghest = [date_ghest]));





如需了解更多信息,请参阅:

参数声明(Microsoft Access SQL) [ ^ ]


这篇关于访问2010和C#.net中的查询是否错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆