属性具有无效大小值
<%@ page debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<html>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
'创建数据连接对象
Dim IConn As SQLConnection
'创建命令集对象
Dim IComm As SQLCommand
'创建数据集
Dim DS As DataSet
Dim DA as SQLDataAdapter=new SQLDataAdapter()
IConn = New SQLConnection("server=localhost;uid=sa;pwd=867251;database=NETBBS")
IComm = New SQLCommand("pro_outpara", IConn)
'创建命令集为存储过程!
IComm.CommandType = CommandType.StoredProcedure
'获得并传入参数:
IComm.Parameters.Add(New SQLParameter("@count",Type.gettype("system.integer")))
IComm.Parameters("@count").Direction = ParameterDirection.Output
'填充数据集
DS = new DataSet()
DA.selectCommand=ICOmm
DA.Fill(DS, "topic")
'数据绑定
'IDG.DataSource=DS.Tables("topic").DefaultView
'IDG.DataBind()
If Not Page.IsPostBack Then
TotalPages.Text = System.Math.Ceiling(IComm.Parameters("@count").Value)
End If
End Sub
</script>
<body bgcolor="#ccccff" style="font: 10pt verdana">
<br><br><br>
<center>
.NET->有输出参数的存储过程的输出结果: <br><br><br>
文章总数:<asp:Label id="TotalPages" runat="server" />
</center>
</body>
</html>
错误是DA.Fill(DS, "topic")时
报
System.InvalidOperationException: 参数 0: String 类型的“@count”,Size 属性具有无效大小值: 0
存储过程是CREATE procedure pro_outpara
@count integer output
as
select @count= (select count(*) from topic)
GO