i have aspnet_Roles
ROLID ROLNAME
9acf74a8-d48b-4541-815e-695117a7a093 Admin
88299f05-b2aa-41c2-81f5-69959777677c AltinUye
5712cd36-406c-490e-9da0-235fcec32186 NormalUye
i have my aspnet_UsersInRoles
USERID ROLEID
fbd74e8b-f5e6-44a9-9fd4-1930beafb0e3 9acf74a8-d48b-4541-815e-695117a7a093
e64aa732-8631-46e6-90bb-0d2b882a21e3 88299f05-b2aa-41c2-81f5-69959777677c
241e204e-530e-4917-97b6-4a14f7057e1f 88299f05-b2aa-41c2-81f5-69959777677c
ca5999b8-f076-482d-9be4-709efd0ce550 88299f05-b2aa-41c2-81f5-69959777677c
0e6789fe-b6fd-4ac5-8da9-f8eb661ae31f 88299f05-b2aa-41c2-81f5-69959777677c
My stored procedure is
ALTER proc [dbo].[RolDuzenle]
(
@UserId uniqueidentifier,
@RolId uniqueidentifier,
@Result int output
)
as
Declare @RecordControl int
Set @RecordControl=(select count(*) from dbo.aspnet_UsersInRoles where UserId=@UserId and RoleId=@RolId)
update dbo.aspnet_UsersInRoles set RoleId=@RolId where UserId=@UserId
if(@RecordControl=0)
begin
set @Result=0
end
else
begin
set @Result=1
end
return @Result
Baglanti baglan = new Baglanti();
SqlParameter[] paramdizi2 = new SqlParameter[3]
{
new SqlParameter(";@UserId",SqlDbType.UniqueIdentifier),
new SqlParameter("@RolId",SqlDbType.UniqueIdentifier),
new SqlParameter("@Result",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 = "Rol Updated";
}
else
{
LabelDurum.Text = "The role is already same";
}
ı managed this part.ı did it but;
i want to get the result below
Baglanti baglan = new Baglanti();
SqlParameter[] paramdizi2 = new SqlParameter[3]
{
new SqlParameter("@UserId";,SqlDbType.UniqueIdentifier),
new SqlParameter("@RolId";,SqlDbType.UniqueIdentifier),
new SqlParameter("@Result",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 = "Role updated";
}
else
{
LabelDurum.Text = "The table doesnt include this RoleId";
}
if ı used RolDuzenle stored procedure but, ı dont arrive this result
{
LabelDurum.Text = "Role updated";
}
else
{
LabelDurum.Text = "The aspnet_Roles table doesnt include this RoleId"
}
İf ı enter false Role Id my program is failed.
The UPDATE statement conflicted with the FOREIGN KEY constraint "FK__aspnet_Us__RoleI__52593CB8". The conflict occurred in database "TskYurt", table"dbo.aspnet_Roles, column 'RoleId';.
The statement has been terminated.
IS IT POSSIBLE?
i want to this
if (paramdizi2[2].Value.ToString() == "0")
{
LabelDurum.Text = "Role updated";
}
else
{
LabelDurum.Text ="The aspnet_Roles table doesnt include this RoleId";
}