调用存储过程,返回表,求找错误!!在线等
我的存储过程如下,我想返回查询结果
CREATE PROCEDURE [Contrast_Capital_Ordering]@Basic_Code_Re_Last int,@Basic_Code_Re intASBEGINselect * into #A from Ordering_Data where Basic_Code_Re=@Basic_Code_Re_Last ------A表为上次select * into #B from Ordering_Data where Basic_Code_Re=@Basic_Code_Re -------B表为本次select ISNULL(#A.Price_Code,#B.Price_Code) 编码,ISNULL(#A.Yellow_Num,0) 上次黄,ISNULL(#B.Green_Num,0)本次绿,ISNULL(#A.Yellow_Date,null) 上次黄日期,ISNULL(#B.Green_Date,null) 本次绿日期from #A full join #B on #A.Price_Code = #B.Price_CodeRETURNEND
public string Contarst(int Basic_Code_Re_Last, int Basic_Code_Re, out DataSet result)//对比存储过程 { DataSet ds = new DataSet(); a.open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Contrast_Capital_Ordering"; //存储过程名 cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = a.connstr; SqlParameter[] parameters ={ new SqlParameter("@Basic_Code_Re_Last",SqlDbType.Int,4), new SqlParameter("@Basic_Code_Re",SqlDbType.Int,4), }; parameters[0].Value = Basic_Code_Re_Last;//上次订单号. parameters[1].Value = Basic_Code_Re;//本次订单号 foreach (SqlParameter p in parameters) { cmd.Parameters.Add(p); } SqlDataAdapter rs = new SqlDataAdapter(cmd); rs.Fill(ds); a.close(); return ds; }
exec Contrast_Capital_Ordering 1234,3456
[解决办法]