仅在 VB6 中显示选定的值 [英] Displaying selected values only in VB6

查看:29
本文介绍了仅在 VB6 中显示选定的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在是"处于活动状态的数据网格中显示学生.如果学生的否"处于活动状态,则表格必须将其隐藏并仅向学生显示是".我现在收到的问题是

I am trying to display students in a datagrid that have "yes" as active. If the student has "no" as active, the form has to hide it and only show the students with "yes". The problem that I am recieving now is

FROM 子句中的语法错误.

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?
如果 ActiveBoolean 数据类型(是/否),则可选值为 TrueFalse.在这种情况下,您的查询是:

What is Active?
If Active is Boolean data type (Yes/No), it's optional values are True or False. In that case your query is:

"select * from Table1 where Active <> False"

如果ActiveString数据类型;'no''No' 是相同的值吗?你最好将全部转换为小写或大写:

If Active is String data type; are 'no' and 'No' the same values? you are better converting all to lower or upper case:

"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

这篇关于仅在 VB6 中显示选定的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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