【问题标题】:Not able to read from access table properly无法正确读取访问表
【发布时间】:2014-01-25 10:20:32
【问题描述】:

我遇到了一个非常愚蠢的问题。要求是停止访问表中的重复条目。我正在使用VB6。但是每次我尝试时都会遇到语法错误。

我的代码

我的 flexgrid 已填充并刷新。我能够在同一数据库的另一个表中插入和选择数据。但是这个失败了

sql_txt1 = "Select SL_No from SpAIReport where DOM ='" & Format(Now, "mm/dd/yyyy") & _
"'  and AC-REG ='" & msgDisFlex.TextMatrix(i, 4) & "' and Flt No = '" & msgDisFlex.TextMatrix(i, 6) & "'"
Set rs1 = db.OpenRecordset(sql_txt1)

我可以更新此表,但会填充多个时间相同的数据。

下面给出了带有条目的访问表结构

Date_OF_Fly Flt No  GMT Weight  Airtime Station     DOM     Data_hrs                Filename
7/3/2000    11      03:45:01    5       01:23:40    XXX     01/25/2014 120:10:15    ABCD

另外,保存后如果我想通过记录集访问它,那么它会显示NULL

代码是:

sql_txt = "select * from SpAIReport where DOM='" & dateDailyReport & "'"
Set rs = db.OpenRecordset(sql_txt)

dateDailyReport 的值为 01/25/2014。该值存在于数据库中。这个查询仍然不起作用。

请帮忙。

【问题讨论】:

    标签: ms-access vb6


    【解决方案1】:

    您可能希望将“Flt No”和“AC-REG”放在方括号中,否则它们看起来像两个字段名称:

     "'  and [AC-REG] ='" & msgDisFlex.TextMatrix(i, 4) & "' and [Flt No] = '" & 
    

    【讨论】:

    • 感谢您的帮助。我在 flt no : the space 和 AC-REG : the hiphen 中犯了错误。使用下划线更改名称后,它可以正常工作...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-13
    • 2021-12-07
    • 2012-04-11
    • 2019-05-22
    • 2019-11-13
    • 2012-02-20
    相关资源
    最近更新 更多