关于存储过程使用的问题,谁帮忙解答下呀
2006-10-19 19:00
344 查看
所使用的存过过程代码如下:
ALTER PROCEDURE GetProductContent
(@ProductID int,
@ProductName char(20) output,
@Introduction char(200) output
)
AS
select @ProductName=[ProductName],@Introduction=[Introduction] from Product where [ProductID]=@ProductID
select InfoName,Infomation from ProductInfo where [ProductID]=@ProductID
RETURN
在asp.net中用如下代码可以正常访问:
connection.Open();
command.ExecuteNonQuery();
producteg.Introduction = command.Parameters["@Introduction"].Value.ToString();
producteg.ProductName = command.Parameters["@ProductName"].Value.ToString();
producteg.infolist = command.ExecuteReader(CommandBehavior.CloseConnection);
为什么写成下面这样就不行?
connection.Open();
producteg.infolist = command.ExecuteReader(CommandBehavior.CloseConnection);
connection.Open();
command.ExecuteNonQuery();
producteg.Introduction = command.Parameters["@Introduction"].Value.ToString();
producteg.ProductName = command.Parameters["@ProductName"].Value.ToString();
connection.Close();
这样会出错,查看错误信息,command.executerader方法没有返回任何数据,这是为什么?
ALTER PROCEDURE GetProductContent
(@ProductID int,
@ProductName char(20) output,
@Introduction char(200) output
)
AS
select @ProductName=[ProductName],@Introduction=[Introduction] from Product where [ProductID]=@ProductID
select InfoName,Infomation from ProductInfo where [ProductID]=@ProductID
RETURN
在asp.net中用如下代码可以正常访问:
connection.Open();
command.ExecuteNonQuery();
producteg.Introduction = command.Parameters["@Introduction"].Value.ToString();
producteg.ProductName = command.Parameters["@ProductName"].Value.ToString();
producteg.infolist = command.ExecuteReader(CommandBehavior.CloseConnection);
为什么写成下面这样就不行?
connection.Open();
producteg.infolist = command.ExecuteReader(CommandBehavior.CloseConnection);
connection.Open();
command.ExecuteNonQuery();
producteg.Introduction = command.Parameters["@Introduction"].Value.ToString();
producteg.ProductName = command.Parameters["@ProductName"].Value.ToString();
connection.Close();
这样会出错,查看错误信息,command.executerader方法没有返回任何数据,这是为什么?
相关文章推荐
- java中使用堆外内存,关于内存回收需要注意的事和没有解决的遗留问题(等大神解答)
- Ajax小系统使用效果,以及出现的问题(待朋友帮忙解答)
- 关于使用二进制流上传的问题,求大神解答
- 关于使用二进制流上传的问题,求大神解答
- “关于使用反射机制得到泛型的字段名的问题”的解答
- 关于使用二进制流上传的问题,求大神解答
- 关于在使用c3p0 连接池配置数据库连接时出现 com.mchange.v2.resourcepool.CannotAcquireResourceExceptiond问题的解答
- 关于如何获得使用[迅播播放器]播放过的电影的问题,及如何删除播放过的文件的解答(一).
- 关于SQL2005使用中遇到的问题及解答
- 关于mysql导出数据库后,再进行还原时,视图无法使用的问题,请各位大神帮忙出招
- 关于OLEDB数据源中使用存储过程生成数据源报错的问题
- 关于C#中使用messagebox的问题解答
- 关于asp.net的一点小问题有谁帮忙解答一下?
- 使用VC6时:关于WinAPI的版本问题。
- VC中一个关于宏的使用问题
- 关于IIS在使用中遇到的一些问题的总结
- 关于在Android中使用JavaCV的问题
- 关于AO和AE中使用小问题(新手理解)
- 关于Installshield里一些常见问题的解答—艾泽拉斯之海洋女神出品
- 使用存储过程遇到的一些问题