在Access中更新数据时出现问题

编程入门 行业动态 更新时间:2024-10-18 14:23:47
本文介绍了在Access中更新数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用另一个表更新表,这样当一个表不包含值时,另一个表会更新。 我正在使用的查询是:

I am updating a table using another table such that when one table doesn''t contain a value the other table is updated. The Query that I am using is:

Update History set Termination_date = ''date'', Termination_time = ''time'', Link_Status=''1'' WHERE Name NOT IN (SELECT NAME FROM IP_State_Down)

当通过ACCESS使用时,查询的工作方式就像魔术一样,但是当它像这样嵌入时:

When used via ACCESS the Query works like magic but when it is embedded like this:

string Date1 = System.DateTime.Now.ToShortDateString(); string Time1 = System.DateTime.Now.ToLongTimeString(); string DateTime1 = Date1 + " " + Time1; string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Database\\aharchi.mdb"; OleDbConnection conn = new OleDbConnection(connStr); OleDbCommand com = new OleDbCommand(); conn.Open(); com.Connection = conn; com.CommandText = "Update History set Termination_date = ''Date1'', Termination_time = ''Time1'', Link_Status=''1'' WHERE Name NOT IN (SELECT NAME FROM IP_State_Down)"; com.ExecuteNonQuery(); conn.Close();

代码不能像预期的那样工作。请让我知道该怎么做 我真的很抱歉所有!!!!问题被确定来自程序的另一部分而不是这件

the code doesn''t work like it''s intended. Please let me know what to do I am really sorry ALL!!!! The problem was identified to be from another part of the program not this piece

推荐答案

(...)代码没有像预期的那样工作(...) 可能是因为: Hi, (...) the code doesn''t work like it''s intended (...) Probably because: string Date1 = System.DateTime.Now.ToShortDateString(); string Time1 = System.DateTime.Now.ToLongTimeString(); string DateTime1 = Date1 + " " + Time1; string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\Database\\aharchi.mdb"; OleDbConnection conn = new OleDbConnection(connStr); OleDbCommand com = new OleDbCommand(); conn.Open(); com.Connection = conn; com.CommandText = "Update History set Termination_date = '" + Date1 + "', Termination_time = '" + Time1 + "', Link_Status='1' WHERE Name NOT IN (SELECT NAME FROM IP_State_Down)"; com.ExecuteNonQuery(); conn.Close();

用粗体注意代码。 祝你好运。

Pay attention to the code with bold. Good luck.

更多推荐

在Access中更新数据时出现问题

本文发布于:2023-11-23 20:38:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622797.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   Access

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!