如果想返回记录数,请修改存储过程: SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GOCREATE PROCEDURE dbo.GetBookByBookID @ID nchar(13), @Name nvarchar(80)=NULL OUTPUT, @ISBN nchar(13)=NULL OUTPUT, @SearchIndex nvarchar(20)=NULL OUTPUT, @LibraryID INT=NULL OUTPUT, @LocationID INT=NULL OUTPUT, @LocationDescribe nvarchar(20)=NULL OUTPUT, @Borrowed bit=NULL OUTPUT, @Lost bit=NULL OUTPUT, @Preengated bit=NULL OUTPUT, @AllowBorrow bit=NULL OUTPUT, @PressName nvarchar(60)=NULL OUTPUT ASselect count(*) as rowcount from (SELECT @Name=BookName, @ISBN=ISBN, @SearchIndex=SearchIndex, @LibraryID=LibraryID, @LocationID=Books.LocationID, @LocationDescribe=Locations.Describe, @Borrowed=Borrowed, @Lost=Lost, @Preengated=Preengated, @AllowBorrow=AllowBorrow, @PressName=PressName FROM Books,Locations,Presses WHERE Books.BookID=@ID AND Presses.PressID=Books.PressID AND Locations.LocationID=Books.LocationID) tmptableRETURN @@RowCount GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO 并在程序中使用这个语句:int nRowCount=(int)(commond.ExecuteScalar())
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GOCREATE PROCEDURE dbo.GetBookByBookID
@ID nchar(13),
@Name nvarchar(80)=NULL OUTPUT,
@ISBN nchar(13)=NULL OUTPUT,
@SearchIndex nvarchar(20)=NULL OUTPUT,
@LibraryID INT=NULL OUTPUT,
@LocationID INT=NULL OUTPUT,
@LocationDescribe nvarchar(20)=NULL OUTPUT,
@Borrowed bit=NULL OUTPUT,
@Lost bit=NULL OUTPUT,
@Preengated bit=NULL OUTPUT,
@AllowBorrow bit=NULL OUTPUT,
@PressName nvarchar(60)=NULL OUTPUT
ASselect count(*) as rowcount
from
(SELECT
@Name=BookName,
@ISBN=ISBN,
@SearchIndex=SearchIndex,
@LibraryID=LibraryID,
@LocationID=Books.LocationID,
@LocationDescribe=Locations.Describe,
@Borrowed=Borrowed,
@Lost=Lost,
@Preengated=Preengated,
@AllowBorrow=AllowBorrow,
@PressName=PressName
FROM
Books,Locations,Presses
WHERE
Books.BookID=@ID AND
Presses.PressID=Books.PressID AND
Locations.LocationID=Books.LocationID) tmptableRETURN @@RowCount
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
并在程序中使用这个语句:int nRowCount=(int)(commond.ExecuteScalar())