FROM 子句 VB6 中的语法错误

Syntax error in FROM clause VB6

我希望我的程序只显示数据库中的活跃学生。如果学生已存档为否,则会显示它们,但如果学生已存档,则会隐藏它们。每次我播放程序时,它都会显示 Adodc1.Refresh 中的错误:

Syntax error in FROM clause.

代码:

    Dim sql As String

    connSearch.Open connstr
    Adodc1.ConnectionString = conn.connstr
    sql = "select * from Table1 where [Archived] <> 'NO'"
    Adodc1.RecordSource = sql
    Set StudentTable.DataSource = Adodc1
    Adodc1.Refresh ''''The error is in this line.''''
    Adodc1.Visible = False

我解决了这个问题,我需要在代码中添加 adcmdText 才能正常工作。谢谢微软帮助 https://support.microsoft.com/en-us/kb/238279

Dim sql As String

sql = "select * from Table1 where [Active] <> 'No'"
Adodc1.ConnectionString = conn.connstr
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = sql
Set StudentTable.DataSource = Adodc1
Adodc1.Refresh
Adodc1.Visible = False