我有一个类型化的数据集userProfile,它与我的数据库中的用户表相同。 我正在使用存储过程更改密码并返回同一用户的单行。但是当我在.cs代码中使用此过程时,sql异常告诉
[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: }
但我的密码被更改了..
这是我的存储过程
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
但如果我在结尾写了select语句,那么就不会产生错误
plz help
答案 0 :(得分:1)
尝试:
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 }