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 2005 Forums
 Express Edition and Compact Edition (2005)
 Invalid Column Name

Author  Topic 

jcdisciple
Starting Member

5 Posts

Posted - 2009-10-16 : 16:52:30
Here is the error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'pSortOrder'.

/vsadmin/inc/incproducts.asp, line 248

(I BOLDED INTENTIONALLY)

Here is my query:

	sectionids = getsectionids(catid, false)
sSQL = "SELECT DISTINCT products.pID,pSortOrder,"&getlangid("pName",1)&","&WSP&"pPrice,pDateAdded,pOrder FROM products LEFT JOIN multisections ON products.pID=multisections.pID WHERE pDisplay<>0 AND (products.pSection IN (" & sectionids & ") OR multisections.pSection IN (" & sectionids & "))"
end if
if useStockManagement AND noshowoutofstock=TRUE then sSQL = sSQL & " AND (pInStock>0 OR pStockByOpts<>0)"
if request.form("sortby")<>"" then session("sortby")=int(request.form("sortby"))
if session("sortby")<>"" then sortBy=int(session("sortby"))
if sortBy="1" then
sSortBy = " ORDER BY pPrice"
elseif sortBy=2 then
sSortBy = " ORDER BY products.pID"
elseif sortBy=3 then
sSortBy = " ORDER BY "&TWSP
elseif sortBy=4 then
sSortBy = " ORDER BY "&TWSP&" DESC"
elseif sortBy=5 then
sSortBy = ""
elseif sortBy=6 then
sSortBy = " ORDER BY pSortOrder"
elseif sortBy=7 then
sSortBy = " ORDER BY pOrder DESC"
elseif sortBy=8 then
sSortBy = " ORDER BY pDateAdded"
elseif sortBy=9 then
sSortBy = " ORDER BY pDateAdded DESC"
else
sSortBy = " ORDER BY "&getlangid("pName",1)
end if
rs.CursorLocation = 3 ' adUseClient
rs.CacheSize = adminProdsPerPage
rs.Open sSQL & sSortBy, cnn
if NOT rs.EOF then
rs.MoveFirst
rs.PageSize = adminProdsPerPage
If NOT isnumeric(Request.QueryString("pg")) OR trim(Request.QueryString("pg"))="" Then
CurPage = 1
Else
CurPage = vrmax(1, Int(Request.QueryString("pg")))
End If
iNumOfPages = Int((rs.RecordCount + (adminProdsPerPage-1)) / adminProdsPerPage)
rs.AbsolutePage = CurPage
end if
Count = 0
if NOT rs.EOF then
prodlist = ""
addcomma=""
Do While Not rs.EOF And Count < rs.PageSize
prodlist = prodlist & addcomma & "'" & rs("pId") & "'"
rs.MoveNext
Count = Count + 1
addcomma=","
loop
rs.Close
Count = 0
wantmanufacturer = (manufacturerfield<>"" OR (useproductbodyformat=3 AND instr(cpdcolumns, "manufacturer")>0))
sSQL = "SELECT products.pId,pRewriteURL,pSKU,"&getlangid("pName",1)&",pImage,pImage2,pImage3,pImage4,pImage5,"&WSP&"pPrice,pListPrice,pSection,pSell,pStockByOpts,pStaticPage,pShowOnChart,pInStock,pExemptions,pLargeImage,pTax,pTotRating,pNumRatings,"&IIfVr(wantmanufacturer,"mfName,","")&getlangid("pProductBulletPoints",2)&","&IIfVr(wantmanufacturer,"mfName,","")&getlangid("pDescription",2)&","&IIfVr(wantmanufacturer,"mfName,","")&getlangid("pDescription3",2)&","&getlangid("pLongDescription",4)&" FROM products "&IIfVr(wantmanufacturer,"LEFT OUTER JOIN manufacturer on products.pManufacturer=manufacturer.mfID ","")&" WHERE pId IN (" & prodlist & ")" & sSortBy
(HERE IS LINE #248) rs.Open sSQL, cnn, 0, 1
end if

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-10-16 : 17:07:38
is pSortOrder a column in either of these tables (products, multisections) ?

Be One with the Optimizer
TG
Go to Top of Page

jcdisciple
Starting Member

5 Posts

Posted - 2009-10-17 : 00:16:48
Yes, pSortOrder is a new column I created for the multisections table, which have a pID, pSection.

My intention is to be able to have more control over the sort order of products in each section, but not by the default pOrder.

In Query Builder, the SQL works fine, but not when I edited the code would it work correctly.
Go to Top of Page
   

- Advertisement -