开发者

error with dataset

I have a typed dataset userProfile which is same as a user table in my data base. I am using a stored procedure which changes a password and开发者_如何学编程 return a single row of the same user.But when i am using this procedure in .cs code an sql exception telling

[There is no row at position 0.]

in public UserRow this[int index] {
Line 413:                get {
Line 414:                    return ((UserRow)(this.Rows[index]));
Line 415:                }
Line 416:            }

but my password in being changed..

this is my stored procedure

ALTER proc [dbo].[sp_Campaign_PasswordChange]
@username varchar(50),
@old_password varchar(50),
@new_password varchar(50)

as

BEGIN TRY
BEGIN TRANSACTION
if exists(select "USER_ID" from "User" where User_Login_Id=@username and Password=@old_password)
   begin

   select User_Id  from "User" where User_Login_Id=@username
   update "User" set Password=@new_password where User_Login_Id=@username


   end 

   else
   RAISERROR ('username or password does not exists',10,1)


 COMMIT TRANSACTION      




END TRY     

BEGIN CATCH
ROLLBACK TRANSACTION
RETURN @@ERROR
END CATCH

but if i write the select statement at the end then no error is generated

plz help


Try:

public UserRow this[int index] {
          get {
                  if(this.Rows.Count > 0)
                {
                   return ((UserRow)(this.Rows[index]));
                }
 return null;
           }
  }

var row = this[0];

if (row != null){ // Do something }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜