i have three tables in all users,roles,groups
i am trying to delete userid and groupid from the roles table on selecting userid from the user table . can anyone figure out wots the problem in query.
i wrote a query but it is deleting all the records of userid and roleid in the roles table.
The query i am trying is
SqlCommand cmd = new SqlCommand("Delete ROLES SELECT userid FROM users WHERE username= '" + lbldeletename.Text + "'", MAconn);
and the whole code for rowdeleting event in datagridview is
Collapse | Copy Code
protected void _rowdeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
Label lbldeletename = (Label)row.FindControl("lblusername");
MAconn.Open();
SqlCommand cmd = new SqlCommand("Delete ROLES SELECT userid FROM users WHERE username= '" + lbldeletename.Text + "'", MAconn);
cmd.ExecuteNonQuery();
MAconn.Close();
bind();
}