?
Solved

SQL Calculation Error

Posted on 2009-05-09
14
Medium Priority
?
331 Views
Last Modified: 2012-05-06
Hi Experts,

My sql calculation keeps giving me an error.

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

Invalid column name 'dreamID'.

/gmmcPub/dreamsReview.asp, line 62

I'm trying to figure out why I'm getting this error.
<%
Dim rsDreamsCalculate__MMColParam
rsDreamsCalculate__MMColParam = "1"
If (Session("MM_userID") <> "") Then 
  rsDreamsCalculate__MMColParam = Session("MM_userID")
End If
%>
<%
Dim rsDreamsCalculate
Dim rsDreamsCalculate_cmd
Dim rsDreamsCalculate_numRows
 
Set rsDreamsCalculate_cmd = Server.CreateObject ("ADODB.Command")
rsDreamsCalculate_cmd.ActiveConnection = MM_connGMMCdata_STRING
rsDreamsCalculate_cmd.CommandText = "SELECT dreamID, memberID, dreamDate, InHowManyMonths, HavingDream1, HavingDream2, HavingDream3,  HavingDream4, HavingDream5, BeingDream1, BeingDream1ToDo, BeingDream2, BeingDream2ToDo, BeingDream3, BeingDream3ToDo, BeingDream4, BeingDream4ToDo, BeingDream5, BeingDream5ToDo, DoingDream1, DoingDream2, DoingDream3, DoingDream4, DoingDream5, StepsNow, Tomorrow, NextDay, TMI, TDI, HavingDreamTotalCost, BeingDreamTotalCost, DoingDreamTotalCost, TotalDreamCost, COALESCE(HavingDream1Cost, 0) + COALESCE(HavingDream2Cost, 0) + COALESCE(HavingDream3Cost, 0) + COALESCE(HavingDream4Cost, 0) + COALESCE(HavingDream5Cost, 0)  as HavingDreams , COALESCE(BeingDream1Cost, 0) + COALESCE(BeingDream2Cost, 0) + COALESCE(BeingDream3Cost, 0) + COALESCE(BeingDream4Cost, 0) + COALESCE(BeingDream5Cost, 0) as BeingDreams , COALESCE(DoingDream1Cost, 0) + COALESCE(DoingDream2Cost, 0) +  COALESCE(DoingDream3Cost, 0) + COALESCE(DoingDream4Cost, 0) + COALESCE(DoingDream5Cost, 0) as DoingDreams --grandtotal=havingdreams+beingdreams+doingdreams FROM dbo.dreams WHERE memberID = ?" 
rsDreamsCalculate_cmd.Prepared = true
rsDreamsCalculate_cmd.Parameters.Append rsDreamsCalculate_cmd.CreateParameter("param1", 3, 1, -1, rsDreamsCalculate__MMColParam) ' adInteger
 
Set rsDreamsCalculate = rsDreamsCalculate_cmd.Execute
rsDreamsCalculate_numRows = 0
%>

Open in new window

0
Comment
Question by:GMMC_man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24346874
seems like the table 'Dreams' doesnt contain the column 'DreamID'. it may be mispelled
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24346894
yes, DremaID is either mispelled or not exists in table "Dream", can you double check it once?
0
 

Author Comment

by:GMMC_man
ID: 24347946
I've checked and checked. dreamID is how the field is spelled. It is an auto increment id integer.
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 
LVL 31

Expert Comment

by:RiteshShah
ID: 24348298
hhmmmm, I gotcha....... try below in your code.
"SELECT dreamID, memberID, dreamDate, InHowManyMonths, HavingDream1, HavingDream2, HavingDream3,  HavingDream4, HavingDream5, BeingDream1, BeingDream1ToDo, BeingDream2, BeingDream2ToDo, BeingDream3, BeingDream3ToDo, BeingDream4, BeingDream4ToDo, BeingDream5, BeingDream5ToDo, DoingDream1, DoingDream2, DoingDream3, DoingDream4, DoingDream5, StepsNow, Tomorrow, NextDay, TMI, TDI, HavingDreamTotalCost, BeingDreamTotalCost, DoingDreamTotalCost, TotalDreamCost, COALESCE(HavingDream1Cost, 0) + COALESCE(HavingDream2Cost, 0) + COALESCE(HavingDream3Cost, 0) + COALESCE(HavingDream4Cost, 0) + COALESCE(HavingDream5Cost, 0)  as HavingDreams , COALESCE(BeingDream1Cost, 0) + COALESCE(BeingDream2Cost, 0) + COALESCE(BeingDream3Cost, 0) + COALESCE(BeingDream4Cost, 0) + COALESCE(BeingDream5Cost, 0) as BeingDreams , COALESCE(DoingDream1Cost, 0) + COALESCE(DoingDream2Cost, 0) +  COALESCE(DoingDream3Cost, 0) + COALESCE(DoingDream4Cost, 0) + COALESCE(DoingDream5Cost, 0) as DoingDreams --grandtotal=havingdreams+beingdreams+doingdreams FROM dbo.dreams WHERE memberID = ?" 

Open in new window

0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24348307
sorry, use this one.  typo in above.
"SELECT dreamID, memberID, dreamDate, InHowManyMonths, HavingDream1, HavingDream2, HavingDream3,  HavingDream4, HavingDream5, BeingDream1, BeingDream1ToDo, BeingDream2, BeingDream2ToDo, BeingDream3, BeingDream3ToDo, BeingDream4, BeingDream4ToDo, BeingDream5, BeingDream5ToDo, DoingDream1, DoingDream2, DoingDream3, DoingDream4, DoingDream5, StepsNow, Tomorrow, NextDay, TMI, TDI, HavingDreamTotalCost, BeingDreamTotalCost, DoingDreamTotalCost, TotalDreamCost, COALESCE(HavingDream1Cost, 0) + COALESCE(HavingDream2Cost, 0) + COALESCE(HavingDream3Cost, 0) + COALESCE(HavingDream4Cost, 0) + COALESCE(HavingDream5Cost, 0)  as HavingDreams , COALESCE(BeingDream1Cost, 0) + COALESCE(BeingDream2Cost, 0) + COALESCE(BeingDream3Cost, 0) + COALESCE(BeingDream4Cost, 0) + COALESCE(BeingDream5Cost, 0) as BeingDreams , COALESCE(DoingDream1Cost, 0) + COALESCE(DoingDream2Cost, 0) +  COALESCE(DoingDream3Cost, 0) + COALESCE(DoingDream4Cost, 0) + COALESCE(DoingDream5Cost, 0) as DoingDreams, grandtotal=havingdreams+beingdreams+doingdreams FROM dbo.dreams WHERE memberID = ?" 

Open in new window

0
 

Author Comment

by:GMMC_man
ID: 24348372
Now getting error - Invalid column name 'havingdreams'.
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24348375
can you show me your table structure? do you have "havingdreams' column?
0
 

Author Comment

by:GMMC_man
ID: 24348399
no havingdreams is created in sql query
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24348402
try this.
SELECT 
dreamID, 
memberID, 
dreamDate, 
InHowManyMonths, 
HavingDream1, 
HavingDream2, 
HavingDream3,  
HavingDream4, 
HavingDream5, 
BeingDream1, 
BeingDream1ToDo, 
BeingDream2, 
BeingDream2ToDo, 
BeingDream3, 
BeingDream3ToDo, 
BeingDream4, 
BeingDream4ToDo, 
BeingDream5, 
BeingDream5ToDo, 
DoingDream1, 
DoingDream2, 
DoingDream3, 
DoingDream4, 
DoingDream5, 
StepsNow, 
Tomorrow, 
NextDay, 
TMI, 
TDI, 
COALESCE(HavingDream1 , 0) + COALESCE(HavingDream2 , 0) + COALESCE(HavingDream3 , 0) + COALESCE(HavingDream4 , 0) + COALESCE(HavingDream5 , 0)  as HavingDreamsTotal , 
 
COALESCE(BeingDream1 , 0) + COALESCE(BeingDream2 , 0) + COALESCE(BeingDream3 , 0) + COALESCE(BeingDream4 , 0) + COALESCE(BeingDream5 , 0) as BeingDreamsTotal , 
 
COALESCE(DoingDream1 , 0) + COALESCE(DoingDream2 , 0) +  COALESCE(DoingDream3 , 0) + COALESCE(DoingDream4 , 0) + COALESCE(DoingDream5 , 0) as DoingDreamsTotal,
 
grandtotal=HavingDreamsTotal+BeingDreamsTotal+DoingDreamsTotal FROM dbo.dreams WHERE memberID = ?

Open in new window

0
 

Author Comment

by:GMMC_man
ID: 24348693
Still getting error
Invalid column name 'HavingDreamsTotal'.

I removed grandtotal line and got this error
Microsoft OLE DB Provider for SQL Server error '80040e07'

Conversion failed when converting the varchar value 'A fully functional church' to data type int.

/gmmcPub/dreamsReview.asp, line 64
0
 
LVL 31

Accepted Solution

by:
RiteshShah earned 1600 total points
ID: 24348702
in your original logic, you were trying to total something but you might not have numeric value in the fields you are making total rather it has value in string like 'A gully functional church' so it can't be use with addition or subtraction etc. have a look at this.
SELECT 
dreamID, 
memberID, 
dreamDate, 
InHowManyMonths, 
HavingDream1, 
HavingDream2, 
HavingDream3,  
HavingDream4, 
HavingDream5, 
BeingDream1, 
BeingDream1ToDo, 
BeingDream2, 
BeingDream2ToDo, 
BeingDream3, 
BeingDream3ToDo, 
BeingDream4, 
BeingDream4ToDo, 
BeingDream5, 
BeingDream5ToDo, 
DoingDream1, 
DoingDream2, 
DoingDream3, 
DoingDream4, 
DoingDream5, 
StepsNow, 
Tomorrow, 
NextDay, 
TMI, 
TDI 
FROM dbo.dreams WHERE memberID = ?

Open in new window

0
 
LVL 5

Expert Comment

by:satheeshm
ID: 24349256
Hi,

Can you please post your table structure.

Thanks,
Satheesh M
0
 
LVL 2

Assisted Solution

by:dzex13
dzex13 earned 400 total points
ID: 24349344
--grandtotal=havingdreams+beingdreams+doingdreams

Replace This string by:

COALESCE(HavingDream1 , 0) + COALESCE(HavingDream2 , 0) + COALESCE(HavingDream3 , 0) + COALESCE(HavingDream4 , 0) + COALESCE(HavingDream5 , 0)  +
COALESCE(BeingDream1 , 0) + COALESCE(BeingDream2 , 0) + COALESCE(BeingDream3 , 0) + COALESCE(BeingDream4 , 0) + COALESCE(BeingDream5 , 0) +
COALESCE(DoingDream1 , 0) + COALESCE(DoingDream2 , 0) +  COALESCE(DoingDream3 , 0) + COALESCE(DoingDream4 , 0) + COALESCE(DoingDream5 , 0) as GrandTotal

0
 

Author Comment

by:GMMC_man
ID: 24349628
That worked - Thanks.

Here's the final code. I was calculating text fields which was throwing an error. After adding Cost to each dream it worked fine. Thanks.

SELECT dreamID, memberID, dreamDate, InHowManyMonths, HavingDream1, HavingDream2, HavingDream3,  HavingDream4, HavingDream5, BeingDream1, BeingDream1ToDo, BeingDream2, BeingDream2ToDo, BeingDream3, BeingDream3ToDo, BeingDream4, BeingDream4ToDo, BeingDream5, BeingDream5ToDo, DoingDream1, DoingDream2, DoingDream3, DoingDream4, DoingDream5, StepsNow, Tomorrow, NextDay, TMI, TDI, COALESCE(HavingDream1Cost , 0) + COALESCE(HavingDream2Cost , 0) + COALESCE(HavingDream3Cost , 0) + COALESCE(HavingDream4Cost , 0) + COALESCE(HavingDream5Cost , 0)  as HavingDreamsTotal , COALESCE(BeingDream1Cost , 0) + COALESCE(BeingDream2Cost , 0) + COALESCE(BeingDream3Cost , 0) + COALESCE(BeingDream4Cost , 0) + COALESCE(BeingDream5Cost , 0) as BeingDreamsTotal , COALESCE(DoingDream1Cost , 0) + COALESCE(DoingDream2Cost , 0) +  COALESCE(DoingDream3Cost , 0) + COALESCE(DoingDream4Cost , 0) + COALESCE(DoingDream5Cost , 0) as DoingDreamsTotal, COALESCE(HavingDream1Cost , 0) + COALESCE(HavingDream2Cost , 0) + COALESCE(HavingDream3Cost , 0) + COALESCE(HavingDream4Cost , 0) + COALESCE(HavingDream5Cost , 0)  + COALESCE(BeingDream1Cost , 0) + COALESCE(BeingDream2Cost , 0) + COALESCE(BeingDream3Cost , 0) + COALESCE(BeingDream4Cost , 0) + COALESCE(BeingDream5Cost , 0) + COALESCE(DoingDream1Cost , 0) + COALESCE(DoingDream2Cost , 0) +  COALESCE(DoingDream3Cost , 0) + COALESCE(DoingDream4Cost , 0) + COALESCE(DoingDream5Cost , 0) as GrandTotal FROM dbo.dreams WHERE memberID = ?
0

Featured Post

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question