你这存储过程都有问题啊~~~
SELECT @tmp_qty1= SUM(qty)
FROM A
where no=@no and sales!=1
where no=@no and sales!=@type
有两个where语句的!!第二个,你这个@sum只是一个返回值,通过定义一个out 的参数即可!!不需要return什么的~~~后台也不需要Fill到DataSet中!!最后if else 最好写上begin end 这样看起来也美观点!!
SELECT @tmp_qty1= SUM(qty)
FROM A
where no=@no and sales!=1
where no=@no and sales!=@type
有两个where语句的!!第二个,你这个@sum只是一个返回值,通过定义一个out 的参数即可!!不需要return什么的~~~后台也不需要Fill到DataSet中!!最后if else 最好写上begin end 这样看起来也美观点!!
摩擦摩擦摩擦摩擦摩擦
csdn居然出新功能了???我以前怎么没发现???
居然支持@人了...而且居然不是好友也可以@那么我来了....
@Z65443344 居然不可以..?@於黾 这次呢?
这功好神奇啊.......@於黾 @wuyojungogo @webdiyer 能喊出来不?
return @sum
--select @sum
END这里无论是改select 还是return,都提示其他信息: 无法找到表 0。所以我觉得问题出在最后这个@sum上,到底要用什么?
大家也不要纠结存储名称,我实际是对的,只是拷的时候没有改。页面如下:
public int getQTYData()
{
string strPart_no = "";
if (HttpContext.Current.Request.Form["part_no"] != null)
strPart_no =DAL.dalFunction.FormatStr(HttpContext.Current.Request.Form["part_no"].ToString().Trim()); SqlConnection con = Web1.ConOpen();
con.Open(); SqlCommand com = new SqlCommand();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = "S";
com.Connection = con;
com.Parameters.Add("@no", strPart_no);
com.Parameters.Add("@type", 1); DataSet set = new DataSet();
SqlDataAdapter dp = new SqlDataAdapter();
dp.SelectCommand = com;
dp.Fill(set);
foreach(DataRow dr in set.Tables[0].Rows)//“System.IndexOutOfRangeException”类型的异常在 System.Data.dll 中发生,但未在用户代码中进行处理其他信息: 无法找到表 0。
{
}
int intQty = 0; SqlDataReader dr1 = com.ExecuteReader();
if (dr1.Read())
{
intQty = Convert.ToInt32(dr1[0].ToString());
}
dr1.Close();
dr1.Dispose(); con.Close();
return intQty;
}