如何在DB2中使用GridView asp.net中的SUM [英] How to make SUM in GridView asp.net from DB2

查看:60
本文介绍了如何在DB2中使用GridView asp.net中的SUM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从DB2 Server中获取特定列的SUM。



当我使用时,我的代码正常工作(从文件名中选择*)但如果我使用(从文件名中选择sum(ibhand))它不工作并给出错误。



我粘贴我的代码以便你能理解:



I want to make SUM of specific columns from DB2 Server.

My code is working when I'm using (Select * from filename) but if i use (Select sum(ibhand) from filename) its not working and given error.

I am pasting my code so you can understand well:

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="DSN=Imports_Img;UserID=abcd;Password=1234;"

ProviderName="<%$ ConnectionStrings:ConnectionStringJDA.ProviderName %>" SelectCommand="SELECT * FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE = 14"></asp:SqlDataSource>
                </td>
            </tr>
            <tr valign="top">
                <td style="background-color: #C0C0C0;" align="left"><

                    &nbsp;</td>
            </tr>
            <tr valign="top">
                <td style="background-color: #C0C0C0;" align="left">
                    <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource3">

                    <HeaderTemplate>
                   <table border="1" width="100%">
                        <tr>
                            <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Sku #</th>
                            <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Store</th>
                            <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Stock in Hand</th>
                        </tr>

                    </HeaderTemplate>

                    <ItemTemplate>
                   <tr>
                       <td align="center" style=" width: 90px;font-size:small;font-family:Tahoma; width:150px"><%# Eval("ibhand")%></td>

                   </tr>
                    </ItemTemplate>
                    <FooterTemplate>







此代码可以使用但如果我使用






This code is working but if I use

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="DSN=Imports_Img;UserID=abcd;Password=1234;"
ProviderName="<%$ ConnectionStrings:ConnectionStringJDA.ProviderName %>" SelectCommand="SELECT SUM(IBHAND) FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE = 14"></asp:SqlDataSource>







我是怎么做的?




How I do this?

推荐答案

ConnectionStrings:ConnectionStringJDA .ProviderName %> SelectCommand = SELECT * FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND IS TORE = 14 > < / asp:SqlDataSource >
< / td >
< / tr >
< tr valign = top >
< td style = b ackground-color:#C0C0C0; align = left > < ;

& nbsp;< ; / td >
< / tr >
< tr valign = top >
< td style = background-color:#C0C0C0; align = left >
< asp:Repeater ID = Repeater2 runat = server DataSourceID = SqlDataSource3 >

< HeaderTemplate >
< table border = 1 width = < span class =code-keyword> 100% >
< tr >
< th style = font-size:small; FONT-FAMILY:宋体;背景色:ActiveCaption;字体重量:粗体;颜色:白色 > Sku#< / th >
< th style = font-size:small; FONT-FAMILY:宋体;背景色:ActiveCaption;字体重量:粗体;颜色:白色 > 存储< / th >
< th style = font-size:small; FONT-FAMILY:宋体;背景色:ActiveCaption;字体重量:粗体;颜色:白色 > 库存在手< / th >
< / tr >

< / HeaderTemplate >

< ItemTemplate >
< tr >
< td align = center style = width:90px; font-size:small; font-family:Tahoma ; width:150px > <% #Eval( ibhand%> < / td >

< span class =code-keyword>< / tr >
< / ItemTemplate >
< FooterTemplate >
ConnectionStrings:ConnectionStringJDA.ProviderName %>" SelectCommand="SELECT * FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE = 14"></asp:SqlDataSource> </td> </tr> <tr valign="top"> <td style="background-color: #C0C0C0;" align="left">< &nbsp;</td> </tr> <tr valign="top"> <td style="background-color: #C0C0C0;" align="left"> <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource3"> <HeaderTemplate> <table border="1" width="100%"> <tr> <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Sku #</th> <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Store</th> <th style=" font-size:small; font-family:Verdana; background-color:ActiveCaption; font-weight:bold; color:White">Stock in Hand</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td align="center" style=" width: 90px;font-size:small;font-family:Tahoma; width:150px"><%# Eval("ibhand")%></td> </tr> </ItemTemplate> <FooterTemplate>







此代码可以使用但如果我使用






This code is working but if I use

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="DSN=Imports_Img;UserID=abcd;Password=1234;"
ProviderName="<%


ConnectionStrings:ConnectionStringJDA.ProviderName%> SelectCommand = SELECT SUM(IBHAND)FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE = 14>< / asp:SqlDataSource>
ConnectionStrings:ConnectionStringJDA.ProviderName %>" SelectCommand="SELECT SUM(IBHAND) FROM MM410LIB.INVBAL WHERE INUMBR = 79610 AND ISTORE = 14"></asp:SqlDataSource>







我是怎么做的?




How I do this?


尝试以下链接 -

使用JQuery显示总和 [ ^ ]

在GridView中显示总和 [ ^ ]

如何计算.net中gridview列的总和 [ ^ ]
Try the following links -
Display the sum using JQuery[^]
Showing the sum in GridView[^]
How to calculate sum of gridview columns in .net [^]


这篇关于如何在DB2中使用GridView asp.net中的SUM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆