2 pqqlam pqqlam 于 2017.09.02 10:14 提问

C# 通过表1字段,对表2和表3做统计,提示form处语法错误,求解决。。。
c#
    using (DataCommand dc = new DataCommand())
    {
        string sqlWhere = "";
        dc.CommandText = @" 
        select zcry, 
            total_sum=(select COUNT(b.TableID) from table2 b 
            where a.zcry=b.create_user
                 and b.CreateTime>@StartDt and b.CreateTime<@EndDt   
            )  ,
            total_dfk=(select COUNT(b.TableID) from table3 b  
            where a.zcry=b.jlr and b.wgcl='数量1'
                 and b.CreateTime>@StartDt and b.CreateTime<@EndDt   
            )  ,
            total_gr=(select COUNT(b.TableID) from table3 b 
            where a.zcry=b.jlr and b.wgcl='数量2'
                 and b.CreateTime>@StartDt and b.CreateTime<@EndDt   
            )  ,
            total_zq=(select COUNT(b.TableID) from table3 b  
            where a.zcry=b.jlr and b.wgcl='数量3'
                 and b.CreateTime>@StartDt and b.CreateTime<@EndDt   
            )  ,
            total_hwb=(select COUNT(b.TableID) from table3 b 
            where a.zcry=b.jlr and b.wgcl='数量4'
                 and b.CreateTime>@StartDt and b.CreateTime<@EndDt   
            )  
        form table1 a where 1=1 ";
        dc.CommandText += sqlWhere + " group by zcry";
        dc.AddParameter("@StartDt", DbType.DateTime).Value = DateTime.Parse(startDP.Text);
        dc.AddParameter("@EndDt", DbType.DateTime).Value = DateTime.Parse(endDP.Text).AddDays(1);
        DataTable dt = dc.ExecuteDataTable();           
        int total_sum=Convert.ToInt32(dt.Compute("sum(total_sum)", ""));
        DataRow dr = dt.NewRow();
        dr[0]="合计";
        dr[1]=dt.Compute("sum(total_sum)", "");
        dr[2]=dt.Compute("sum(total_dfk)", "");
        dr[3]=dt.Compute("sum(total_gr)", "");
        dr[4]=dt.Compute("sum(total_zq)", "");
        dr[5]=dt.Compute("sum(total_hwb)", "");
        dt.Rows.Add(dr);
        grid1.DataSource = dt;
        grid1.DataBind();
    }

2个回答

caozhy
caozhy   Ds   Rxr 2017.09.02 17:01

form 表格
from 从...

这里是from

请先去补习英语(起码达到初中以上),然后再学编程。

yiyelanxin
yiyelanxin   2017.09.04 15:24

楼上犀利 v 5 8 7

Csdn user default icon
上传中...
上传图片
插入图片