Storing Database Result Field in a Variable.

P

Pierre de Beer

Good Day



I have an ASP page that displays records from a SQL database, how do I store
a result field to a variable. I need to use this as a total after displaying
all the records.



FrontPage is showing the total field in each record, and I only want to
display the total at the end of the page. I can hide the fields but are not
able to store the value to a variable.



This is my SQL query



SELECT Trans_Date, Amount, D_C, Tax, Amount_Description, Account_Number,
Tenant_Number, Date_Valid_To, AppId, CostType,
(SELECT SUM(AmountToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId:: AND
CostType = 'MT114')) AS Total,
(SELECT SUM(TaxToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId:: AND
CostType = 'MT114')) AS TotalTax,
FROM CostsPaidDetail
GROUP BY Trans_Date, D_C, Tax, Amount_Description, Account_Number,
Tenant_Number, Date_Valid_To, AppId, CostType, Amount
HAVING (Amount <> '0') AND (AppId = ::AppId:: AND CostType =
'MT114')



The fields that I need to store to the variable are "Total" and "TotalTax"



Any help will be appreciated.



Kind Regards



Pierre
 
S

Stefan B Rusynko

<%
Total = obRS("Total)
TotalTax = obRS("TotalTax)
%>
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Good Day
|
|
|
| I have an ASP page that displays records from a SQL database, how do I store
| a result field to a variable. I need to use this as a total after displaying
| all the records.
|
|
|
| FrontPage is showing the total field in each record, and I only want to
| display the total at the end of the page. I can hide the fields but are not
| able to store the value to a variable.
|
|
|
| This is my SQL query
|
|
|
| SELECT Trans_Date, Amount, D_C, Tax, Amount_Description, Account_Number,
| Tenant_Number, Date_Valid_To, AppId, CostType,
| (SELECT SUM(AmountToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId:: AND
| CostType = 'MT114')) AS Total,
| (SELECT SUM(TaxToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId:: AND
| CostType = 'MT114')) AS TotalTax,
| FROM CostsPaidDetail
| GROUP BY Trans_Date, D_C, Tax, Amount_Description, Account_Number,
| Tenant_Number, Date_Valid_To, AppId, CostType, Amount
| HAVING (Amount <> '0') AND (AppId = ::AppId:: AND CostType =
| 'MT114')
|
|
|
| The fields that I need to store to the variable are "Total" and "TotalTax"
|
|
|
| Any help will be appreciated.
|
|
|
| Kind Regards
|
|
|
| Pierre
|
|
|
|
|
|
|
|
 
P

Pierre de Beer

Thank You for the help but I still can not get this to work, I attempted
Total = obRS("Total") and Total = obRS(Total) and get the eror;
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'obRS'

/SLReport/CostsPaidDetail.asp, line 185

Any idea why?

Kind Regards

Pierre
 
S

Stefan B Rusynko

"obRS" must be the name of your recordset opened by the select in CostsPaidDetail.asp

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Thank You for the help but I still can not get this to work, I attempted
| Total = obRS("Total") and Total = obRS(Total) and get the eror;
| Microsoft VBScript runtime error '800a000d'
|
| Type mismatch: 'obRS'
|
| /SLReport/CostsPaidDetail.asp, line 185
|
| Any idea why?
|
| Kind Regards
|
| Pierre
|
| | > Good Day
| >
| >
| >
| > I have an ASP page that displays records from a SQL database, how do I
| > store a result field to a variable. I need to use this as a total after
| > displaying all the records.
| >
| >
| >
| > FrontPage is showing the total field in each record, and I only want to
| > display the total at the end of the page. I can hide the fields but are
| > not able to store the value to a variable.
| >
| >
| >
| > This is my SQL query
| >
| >
| >
| > SELECT Trans_Date, Amount, D_C, Tax, Amount_Description, Account_Number,
| > Tenant_Number, Date_Valid_To, AppId, CostType,
| > (SELECT SUM(AmountToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId::
| > AND CostType = 'MT114')) AS Total,
| > (SELECT SUM(TaxToSum) FROM CostsPaidDetail WHERE (AppId = ::AppId:: AND
| > CostType = 'MT114')) AS TotalTax,
| > FROM CostsPaidDetail
| > GROUP BY Trans_Date, D_C, Tax, Amount_Description, Account_Number,
| > Tenant_Number, Date_Valid_To, AppId, CostType, Amount
| > HAVING (Amount <> '0') AND (AppId = ::AppId:: AND CostType =
| > 'MT114')
| >
| >
| >
| > The fields that I need to store to the variable are "Total" and "TotalTax"
| >
| >
| >
| > Any help will be appreciated.
| >
| >
| >
| > Kind Regards
| >
| >
| >
| > Pierre
| >
| >
| >
| >
| >
| >
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top