开发者

LIKE Statement trouble

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!


Your Where clause should be

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

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜