Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 invalid column name error

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-25 : 07:39:27
Sue writes "I am getting the following error when executing the following SQL call within my ASP code:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'sVendorNumber'

sSQL = "SELECT sVendorNumber, sUserSuffix, sFirstName, sLastName, sAccountStatus" _
& "FROM tVendorsComSecurity" _
& " WHERE (sVendorNumber = '" & sVendorNum & "')" _
& " ORDER BY sUserSuffix"

The strange thing is that when I code the it as "SELECT *" (see below), instead of specifically listing the fields I want, it works fine...

sSQL = "SELECT *" _
& "FROM tVendorsComSecurity" _
& " WHERE (sVendorNumber = '" & sVendorNum & "')" _
& " ORDER BY sUserSuffix"

which is strange, because it actually returns only data for the Vendor number specified. (I assume this means that the field name sVendorNumber must exist, otherwise it wouldn't have returned data for the one vendor)

Any idea how I can get my SELECT to work with field names specified?

ps. I threw the call into MS Access, and it works fine.
i'm on Windows 2000."

Bambola
Posting Yak Master

103 Posts

Posted - 2003-02-25 : 08:38:02
You are missing a space before the FROM.

sSQL = "SELECT sVendorNumber, sUserSuffix, sFirstName, sLastName, sAccountStatus" _
& " FROM tVendorsComSecurity" _
& " WHERE (sVendorNumber = '" & sVendorNum & "')" _
& " ORDER BY sUserSuffix"

Bambola.

Go to Top of Page
   

- Advertisement -