我有一个存储过程,它检索多行 3 列项目。我正在以 DataTable 的格式检索。当我调试它时,它给了我错误
必须声明标量变量@Ticket。
但我已经宣布了。
存储过程:
BEGIN
Declare @Ticket Numeric(28,0)
Declare @SQL VarChar(Max)
Declare @SQLUpdate VarChar(Max)
Set @SQL='Select @Ticket=Ticket,VendorTicket[Vendor Ticket],Comments From dbo.VendorTickets Where NotifyOn <= GetDate() And IsNull(NotifyOn,0)<>0 '
Exec(@SQL)
Set @SQLUpdate='Update dbo.VendorTicket Set NotifyOn=0 Where Ticket=@Ticket'
Exec(@SQLUpdate)
END
调用存储过程的代码
SqlConnection oConn = null;
DataTable dtReturn = null;
try
{
getConnection(ref oConn, 1);
using (SqlStoredProcedure sspObj = new SqlStoredProcedure("dbo.usp_checkNotification", oConn, CommandType.StoredProcedure))
{
dtReturn = sspObj.ExecuteDataTable();
sspObj.Dispose();
}
closeConnection(ref oConn);
}