Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
My asp code,
SqlParameter[] paramdizi2 = new SqlParameter[3]
{
 new SqlParameter("@UserId";,SqlDbType.UniqueIdentifier),
 new SqlParameter("@RolId";,SqlDbType.UniqueIdentifier),
 new SqlParameter("@Sonuc";,SqlDbType.Int)
};
 paramdizi2[0].Value = new Guid(TxtUserId.Text);
 paramdizi2[1].Value = new Guid(TxtRolId.Text);
 paramdizi2[2].Direction = ParameterDirection.Output;
 baglan.ExecuteNonQuery("RolDuzenle";, CommandType.StoredProcedure, paramdizi2);
 if (paramdizi2[2].Value.ToString() == "0";)
 {
   LabelDurum.Text = "No roleId";
 }
 else
 {
  LabelDurum.Text = "role ıd updated";
 }
}


My stored procedure is now,

ALTER proc [dbo].[RolDuzenle]
(
@UserId uniqueidentifier,
@RolId uniqueidentifier,
@Sonuc int output
)
as
Declare @KayitKontrol int
Set @KayitKontrol=(select count(*) from dbo.aspnet_UsersInRoles where UserId=@UserId and RoleId=@RolId)

update dbo.aspnet_UsersInRoles set RoleId=@RolId where UserId=@UserId
if(@Kayitkontrol=0)
begin
set @Sonuc=0
end
else
begin
set @Sonuc=1
end
return @Sonuc

Thank u for your answer but my problem is going ...

i wrote your sp and changed my aspx code but my program was failed.
Rol ıd RolName
9acf74a8-d48b-4541-815e-695117a7a093 Admin
88299f05-b2aa-41c2-81f5-69959777677c AltinUye
5712cd36-406c-490e-9da0-235fcec32186 NormalUye

if ı write 11111111-d48b-4541-815e-695117a7a093 in txtRolId

my program was failed.

i want to write Not acceptRoleId in labeldurum

but how my problem is going:(
Posted
Updated 13-Jun-11 6:39am
v3
Comments
Ccsnow 13-Jun-11 8:11am    
i want
if ı wrıte false role ıd

LabelDurum.Text = "No roleId";
i write true
LabelDurum.Text = "role ıd updated";
Ccsnow 14-Jun-11 4:36am    
what is my problem? how can ı do for my problem?
Morl99 14-Jun-11 5:11am    
I am sure english is not your native language, but your writing makes no sense to us. Please try to find a better translation or visit a site in your native language as we cannot adequately help you with this.

1 solution

Put @Sonuc INT Output in your stored provedures parameter list

Your procedure should be like

ALTER proc [dbo].[RolDuzenle]
(
@UserId uniqueidentifier,
@RolId   uniqueidentifier,
@Sonuc INT Output
)
as
Declare @KayitKontrol int

Set @KayitKontrol=(select count(*) from dbo.aspnet_UsersInRoles where RoleId=@RolId)
 
update dbo.aspnet_UsersInRoles set RoleId=@RolId   where UserId=@UserId
 
if(@Kayitkontrol=0)
 
begin
 
set @Sonuc=0
end
else
begin
set @Sonuc=1
end
return @Sonuc



make sure that you must send the valid GUID to the procedure.

Hope it helps... :),
 
Share this answer
 
v2
Comments
Ccsnow 13-Jun-11 12:40pm    
thx u but my problem is going my friend

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900