giving authorization to the user
-
hey guys..i try to make a login panel and authorization..first i created a StoredProcedure like below
ALTER proc [dbo].[sp_KullaniciYetkiDegistir]
(
@KullaniciNo int,
@Yetki0 int,
@Yetki1 int,
@Yetki2 int,
@Yetki3 int,
@Yetki4 int
)
As
Begin
update Izin set ErisebilirMi = @Yetki0 where KullaniciNo = @KullaniciNo and YetkiNo = 1
update Izin set ErisebilirMi = @Yetki1 where KullaniciNo = @KullaniciNo and YetkiNo = 2
update Izin set ErisebilirMi = @Yetki2 where KullaniciNo = @KullaniciNo and YetkiNo = 3
update Izin set ErisebilirMi = @Yetki3 where KullaniciNo = @KullaniciNo and YetkiNo = 4
update Izin set ErisebilirMi = @Yetki4 where KullaniciNo = @KullaniciNo and YetkiNo = 5
Endin here i give some authority according to the KullaniciNo(here Erisebilirmi column is set as bit..so i can give or not give authority to the user)...and in my button's click i wrote like that
cmd = new SqlCommand("sp_KullaniciYetkiDegistir", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@KullaniciNo", System.Data.SqlDbType.Int).Value = KullaniciNo;
cmd.Parameters.AddWithValue("@Yetki0", System.Data.SqlDbType.Bit).Value = chkAdmin.Checked;
cmd.Parameters.AddWithValue("@Yetki1", System.Data.SqlDbType.Bit).Value = chkKullaniciEkle.Checked;
cmd.Parameters.AddWithValue("@Yetki2", System.Data.SqlDbType.Bit).Value = chkKullaniciSil.Checked;
cmd.Parameters.AddWithValue("@Yetki3", System.Data.SqlDbType.Bit).Value = chkYekilendir.Checked;
cmd.Parameters.AddWithValue("@Yetki4", System.Data.SqlDbType.Bit).Value = chkProjeGor.Checked;if (cmd.ExecuteNonQuery() == 1) MessageBox.Show("Authorities Are Set", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show("Authorization Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
here cmd.ExecuteNonQuery() drops directly Else block..what is wrong here?? any help will be appreciated
-
hey guys..i try to make a login panel and authorization..first i created a StoredProcedure like below
ALTER proc [dbo].[sp_KullaniciYetkiDegistir]
(
@KullaniciNo int,
@Yetki0 int,
@Yetki1 int,
@Yetki2 int,
@Yetki3 int,
@Yetki4 int
)
As
Begin
update Izin set ErisebilirMi = @Yetki0 where KullaniciNo = @KullaniciNo and YetkiNo = 1
update Izin set ErisebilirMi = @Yetki1 where KullaniciNo = @KullaniciNo and YetkiNo = 2
update Izin set ErisebilirMi = @Yetki2 where KullaniciNo = @KullaniciNo and YetkiNo = 3
update Izin set ErisebilirMi = @Yetki3 where KullaniciNo = @KullaniciNo and YetkiNo = 4
update Izin set ErisebilirMi = @Yetki4 where KullaniciNo = @KullaniciNo and YetkiNo = 5
Endin here i give some authority according to the KullaniciNo(here Erisebilirmi column is set as bit..so i can give or not give authority to the user)...and in my button's click i wrote like that
cmd = new SqlCommand("sp_KullaniciYetkiDegistir", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@KullaniciNo", System.Data.SqlDbType.Int).Value = KullaniciNo;
cmd.Parameters.AddWithValue("@Yetki0", System.Data.SqlDbType.Bit).Value = chkAdmin.Checked;
cmd.Parameters.AddWithValue("@Yetki1", System.Data.SqlDbType.Bit).Value = chkKullaniciEkle.Checked;
cmd.Parameters.AddWithValue("@Yetki2", System.Data.SqlDbType.Bit).Value = chkKullaniciSil.Checked;
cmd.Parameters.AddWithValue("@Yetki3", System.Data.SqlDbType.Bit).Value = chkYekilendir.Checked;
cmd.Parameters.AddWithValue("@Yetki4", System.Data.SqlDbType.Bit).Value = chkProjeGor.Checked;if (cmd.ExecuteNonQuery() == 1) MessageBox.Show("Authorities Are Set", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show("Authorization Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
here cmd.ExecuteNonQuery() drops directly Else block..what is wrong here?? any help will be appreciated
-
Your sproc updates a number of things, and that would cause
ExecuteNonQuery
to return an int larger than 1. How about assigning the result to a variable and displaying that, just to make sure?I are Troll :suss:
-
thanks friend..i did what u said and i noticed that i made mistake in my if block..so it was working already but it is seen like it gives errror because of my wrong idea thanks for help