仅在 VB6 中显示选定值
Displaying selected values only in VB6
我正在尝试在 "yes" 处于活动状态的数据网格中显示学生。如果学生 "no" 处于活动状态,则表单必须将其隐藏并仅显示 "yes" 的学生。
我现在收到的问题是
Syntax error in FROM clause.
代码:
Private Sub Form_Load()
Dim sql As String
connSearch.Open connstr
Adodc1.ConnectionString = conn.connstr
sql = "select * from Table1 where Active <>" & "'No'"
Adodc1.RecordSource = sql
Set StudentTable.DataSource = Adodc1
Adodc1.Refresh
Adodc1.Visible = False
End Sub
什么是 Active
?
如果Active
是Boolean
数据类型(Yes/No),它的可选值为True
或False
。在这种情况下,您的查询是:
"select * from Table1 where Active <> False"
如果Active
是String
数据类型; 'no'
和 'No'
是相同的值吗?您最好将全部转换为小写或大写:
"select * from Table1 where Ucase(Active) <> 'NO'"
编辑:修改代码
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
我正在尝试在 "yes" 处于活动状态的数据网格中显示学生。如果学生 "no" 处于活动状态,则表单必须将其隐藏并仅显示 "yes" 的学生。 我现在收到的问题是
Syntax error in FROM clause.
代码:
Private Sub Form_Load()
Dim sql As String
connSearch.Open connstr
Adodc1.ConnectionString = conn.connstr
sql = "select * from Table1 where Active <>" & "'No'"
Adodc1.RecordSource = sql
Set StudentTable.DataSource = Adodc1
Adodc1.Refresh
Adodc1.Visible = False
End Sub
什么是 Active
?
如果Active
是Boolean
数据类型(Yes/No),它的可选值为True
或False
。在这种情况下,您的查询是:
"select * from Table1 where Active <> False"
如果Active
是String
数据类型; 'no'
和 'No'
是相同的值吗?您最好将全部转换为小写或大写:
"select * from Table1 where Ucase(Active) <> 'NO'"
编辑:修改代码
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