LIKE 语句麻烦

发布于 2024-08-17 18:25:37 字数 1205 浏览 1 评论 0原文

我在 VB 2008 中使用 TableAdapter 和 LIKE 语句时遇到一些问题。我想使用部分拼写来搜索名称。当我运行应用程序时,没有任何返回。

这是我的 SQL:

SELECT        MEMBERS.RolodexID, MEMBERS.FirstName, MEMBERS.LastName, MEMBERS.address, MEMBERS.Address2, MEMBERS.City, MEMBERS.State, 
                         MEMBERS.Zip, MEMBERS.AreaCode1, MEMBERS.LocalNumber1, MEMBERS.AreaCode2, MEMBERS.LocalNumber2, MEMBERS.AreaCode3, 
                         MEMBERS.LocalNumber3, Member_Employers.Department, Member_Employers.Job_Class, EMPLOYER.NAME, MEMBERS.Industry, 
                         EMPLOYER.CODE
FROM            EMPLOYER INNER JOIN
                         Member_Employers ON EMPLOYER.CODE = Member_Employers.Employer_Code INNER JOIN
                         MEMBERS AS MEMBERS ON Member_Employers.Rolodexid = MEMBERS.RolodexID
WHERE        (MEMBERS.LastName like ?)

这是我的 VB 代码:

DIM LastName as String

LastName = me.txt_LastName.text

Me.MEMBERSTableAdapter.FillBy(DataSet1.MEMBERS, LastName)

我尝试了其他一些代码,包括:

LastName = "'" & me.txt_LastName.text & "%'"

LastName = me.txt_LastName.text & "%"

请帮忙!

I am having some issues while using the TableAdapter and the LIKE Statement in VB 2008. I am wanting to search name using partial spellings. When I run the application nothing is returned.

Here is my SQL:

SELECT        MEMBERS.RolodexID, MEMBERS.FirstName, MEMBERS.LastName, MEMBERS.address, MEMBERS.Address2, MEMBERS.City, MEMBERS.State, 
                         MEMBERS.Zip, MEMBERS.AreaCode1, MEMBERS.LocalNumber1, MEMBERS.AreaCode2, MEMBERS.LocalNumber2, MEMBERS.AreaCode3, 
                         MEMBERS.LocalNumber3, Member_Employers.Department, Member_Employers.Job_Class, EMPLOYER.NAME, MEMBERS.Industry, 
                         EMPLOYER.CODE
FROM            EMPLOYER INNER JOIN
                         Member_Employers ON EMPLOYER.CODE = Member_Employers.Employer_Code INNER JOIN
                         MEMBERS AS MEMBERS ON Member_Employers.Rolodexid = MEMBERS.RolodexID
WHERE        (MEMBERS.LastName like ?)

Here is my VB code:

DIM LastName as String

LastName = me.txt_LastName.text

Me.MEMBERSTableAdapter.FillBy(DataSet1.MEMBERS, LastName)

I've tried a couple of other codes including:

LastName = "'" & me.txt_LastName.text & "%'"

or

LastName = me.txt_LastName.text & "%"

Please Help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吾性傲以野 2024-08-24 18:25:37

则应使用Where 子句。

WHERE        (MEMBERS.LastName like '%searchValue%') 

如果您想在 LastName 字段中的任何位置搜索 searchValue,

Your Where clause should be

WHERE        (MEMBERS.LastName like '%searchValue%') 

if you want to search for searchValue anywhere within the LastName field.

怀念你的温柔 2024-08-24 18:25:37

LastName = "%"+me.txt_LastName.text+"%" 就是你想要的。

请注意缺少单引号。我知道这很愚蠢,但这就是它的运作方式。

LastName = "%"+me.txt_LastName.text+"%" is what you want.

Note the lack of single quotes. I know it is silly, but it is how it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文