# 应该这样

Posted by 纪文和 on May 17, 1999 at 02:49:47:

In Reply to: 这样的SQL可以这样写吗? posted by jeff on May 15, 1999 at 09:46:32:

: Set trade = dbs.OpenRecordset("select * from 班级资料 where '" & Text2.Text & "' <> '0' ")

SELECT 的语法是
select fieldname1,fieldname2,... from table1 where fieldname = fieldvalue

在您的 SQL 字串中
Set trade = dbs.OpenRecordset("select * from 班级资料 where '" & Text2.Text & "' <> '0' ")

您搞错了一个地方, where 之后接的应该是 fieldname = fieldvalue,
fieldname 就是--班级名称, fieldvalue 就是 Text2.Text,
所以正确的 SQL 字串应该是

"select 班级名称 from 班级资料 where 班级名称 = '" & Text2.Text & "'"

Follow Ups: