January 17, 2011 at 8:16 pm
the below "if (db.ExecuteNonQuery(dbCommand) > 0)"
returns -1
public static bool IsUserInFavoriteList(int userNameID, int favoriteUserNameID)
{
bool result = false;
Database db = OmegaLoveSqlDataHelper.CreateConnection(ConnnectionString);
DbCommand dbCommand = db.GetStoredProcCommand("prc_IsUserInFavouriteList");
db.AddInParameter(dbCommand, "UserNameID", DbType.Int32, userNameID);
db.AddInParameter(dbCommand, "FavoriteUserNameID", DbType.Int32, favoriteUserNameID);
if (db.ExecuteNonQuery(dbCommand) > 0)
result = true;
return result;
}
[sql]
ALTER PROCEDURE [dbo].[prc_IsUserInFavouriteList]
(
@UserNameIDint,
@FavoriteUserNameIDint
)
AS
BEGIN
IF ((SELECT COUNT(*) FROM tbl_Favorites WHERE @UserNameID = UserNameID
AND @FavoriteUserNameID = FavoriteUserNameID) <> 0)
SELECT CAST ( 1 AS BIT)
ELSE
SELECT CAST( 0 AS BIT)
END
[/sql]
January 20, 2011 at 2:42 am
This seems more of a programming query.
If you use .net, see http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery.aspx
for why it will return -1.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply