ma ouml

ma ouml

  • NA
  • 436
  • 88.1k

How to edit and delete in sql server

May 1 2017 10:04 AM
Hi friends
I hope you are well
I have a problem is that I had a table named authorization in this structure
create table autorisation
(
Id_autorisation int primary key identity NOT NULL,
Id_user int foreign key references utilisateur (Id_user),
Id_site int foreign key references site (Id_site),
Id_profil int foreign key references profil (Id_profil)
)
In visual studio I have this interface
And in the display I two not display Id_autorization and when I want to click on the modifier 
it does not work with this request Program.cmd.CommandText = "authorization 
update 
in Id_site = (select top 1 Id_site site from the site where Libelle_site = '" + comboBox2.Text + "'),
 Id_user = (select top 1 utilisateur User_name = '"+ comboBox1. Text +"'), 
Id_profil = (select top 1 Id_profil from profil where Libelle_profile = '"+ comboBox3.Text +"') 
where Id_user = (select top 1 utilisateur User_name = @par1)"; 
Program.cmd.Parameters.AddWithValue("@par1", comboBox1.Text);
Program.cmd.ExecuteNonQuery (); 
the same problem in delete 
Program.cmd.CommandText = "delete from autorisation where 
Id_user = (select top 1 utilisateur User_name = @par1)"; 
Program.cmd.Parameters.AddWithValue("@par1", comboBox1.Text);
Program.cmd.Parameters.AddWithValue("@del", comboBox1.Text); 
Program.cmd.ExecuteNonQuery();
In short how to do the deletion and modification without writing in the clause where Id_autorisation = ....
And thanks in advance friends

Answers (7)