日期:2014-05-17  浏览次数:21190 次

求解,关于使用参数传Where In语句的一个错误
这是执行SQL语句的方法

        public DataTable GetData(string sql, string ATableName, SqlParameter[] sqlparam)
        {
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            try
            {
                SqlCommand sqlComm = new SqlCommand(sql, GetConnection());
                for (int j = 0; j < sqlparam.Length; j++)
                {
                    sqlComm.Parameters.Add(sqlparam[j]);
                }
                using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))
                {
                    da.Fill(ds, ATableName);
                }
                dt = ds.Tables[0];
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                ColseConnection();
            }
            return dt;
        }

这是传的sql语句

if object_id(N'tempdb..#temp_6e8866c7d2ff438685f272ea0f5b8644',N'U') is not null drop table #temp_6e8866c7d2ff438685f272ea0f5b8644;
Select * into #temp_6e8866c7d2ff438685f272ea0f5b8644 
from 
(
Select DISTINCT a.[组织编号] as col, row_number()over(order by b.n desc)RowNo, ISNULL(b.n,0) as n 
From [View_Statistics] a 
LEFT join 
(
Select DISTINCT [组织编号] as col, COUNT(*) as n