zoukankan      html  css  js  c++  java
  • 某列不属于表,但是列存在

    遇到个棘手的问题,在功能中数据层有个方法是返回一个泛型的方法,发布后在IIS中测试,调用10多次都没有问题,过后就出现这个问题,感觉极为不稳定,然后这个方法一直过不去,要重启IIS才行,而在VS工具中测试从来不报错,报错信息如下: 
    异常详细信息: System.ArgumentException: 列“Props_TypeName”不属于表 Table。

    SQL语句中Props_TypeName,Pi_SmallImg字段都是动态构建的,本身不属于Idol_PropsPurchases这个表,我以前试过用SqlDataReader来读取也报类似错误.所以 
    改为DataTable来操作。 

    public static List<Idol_PropsPurchases> GetPropsBagInfo(int BagId, int Idol_Id)
            {
                List<Idol_PropsPurchases> Lipp = new List<Idol_PropsPurchases>();
                string Sql = "select (select dbo.Props_GetParentName(Pt_Id) from Props_Info where Pi_Id = Ipp.Pi_Id) as Props_TypeName,(select Pi_SmallImg from Props_Info where Pi_Id = Ipp.Pi_Id) as Pi_SmallImg,* from Idol_PropsPurchases Ipp where datediff(s,convert(varchar(20),getdate(),120),Ipp_EndTime)>0 and Ipp_IsUse = 0 and Bag_Id="+BagId+" and Idol_Id="+Idol_Id+"";
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MemberDBCS"].ConnectionString);
                con.Open();
                SqlDataAdapter Sda = new SqlDataAdapter(Sql, con);
                DataSet Ds = new DataSet();//;SqlHelper.GetDataTable(Sql)
                Sda.Fill(Ds);
                DataTable Dt = Ds.Tables[0];
                con.Close();
                    if (Dt.Rows.Count != 0)
                    {
                        foreach (DataRow Row in Dt.Rows)
                        {
                            Idol_PropsPurchases Ipp = new Idol_PropsPurchases();
                            Ipp.Props_TypeName = Row["Props_TypeName"].ToString();
                            Ipp.Pi_SmallImg = Row["Pi_SmallImg"].ToString();
                            Ipp.Pi_Id = int.Parse(Row["Pi_Id"].ToString());
                            Ipp.Ipp_AccumulationCount = int.Parse(Row["Ipp_AccumulationCount"].ToString());
                            Ipp.Ipp_PositionNum = int.Parse(Row["Ipp_PositionNum"].ToString());
                            Ipp.Ipp_IsProps = bool.Parse(Row["Ipp_IsProps"].ToString());
                            Lipp.Add(Ipp);
                        }
                    }
                
                
                return Lipp;
            }
    

      

  • 相关阅读:
    测序深度和覆盖度(Sequencing depth and coverage)
    让linux中 history显示每条命令的操作时间及操作用户【转】
    python报错IndexError: list index out of range
    优化MySQL的21个建议 – MySQL Life【转】
    Memcached实战之复制----基于repcached的主从【转】
    从xtrabackup备份恢复单表【转】
    binlog2sql的安装及使用
    mydumper安装及使用
    MySQL5.7 GTID在线开启与关闭【转】
    linux动态追踪神器——Strace实例介绍【转】
  • 原文地址:https://www.cnblogs.com/wangguowen27/p/2624427.html
Copyright © 2011-2022 走看看