简体   繁体   中英

Microsoft OLE DB Provider for SQL Server error '80040e14' Invalid column name . SQL query

Hi I have having this error message

Microsoft OLE DB Provider for SQL Server error '80040e14'

Invalid column name 'gonzalez'.

When I try to run this query I just made. This website has a search box that I type in that searches all the last names in corporate directory.

    SecurityQuery = "SELECT * FROM dbCorpDir.dbo.vwEmployees WHERE sn like '" & FormatDBTextSearch(Last_Name) & "' ORDER BY sn;"

this works fine in SSMS

    SELECT * FROM dbCorpDir.dbo.vwEmployees WHERE sn like 'gonzalez' ORDER BY sn;

Ok guys just for future reference I will post what I found.I removed the single quotes. But I needed to rename the output fields to the column names of the new database.(DUH)! I kept relying on the debugger telling me what line the error was on and it was wrong. Thanks again for all the help.

   SecurityQuery = "SELECT * FROM dbCorpDir.dbo.vwEmployees WHERE sn like " & FormatDBTextSearch(Last_Name) & " ORDER BY sn;"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM