Joaanaa.93 Posted May 24, 2013 at 09:15 AM Report #508708 Posted May 24, 2013 at 09:15 AM Bom dia pessoal, estou a acabar um web site, e estou na rate do backoffice, mas não consigo apagar a informação que pretendo Estou a tentar eliminar assim: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using System.Configuration; namespace WebApplication23.Backoffice { public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void LinkButton1_Click(object sender, EventArgs e) { SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = ConfigurationManager.ConnectionStrings["inovaConn"].ConnectionString; SqlDataSource1.DeleteCommand = "DELETE FROM Revistas_Detail FROM Revistas_Detail INNER JOIN Revistas_Header ON Revistas_Detail.nr_revista = Revistas_Header.nr_revista WHERE (Revistas_Detail.nr_revista = @nr_revista) AND (Revistas_Header.nr_revista = @nr_revista)"; sqlCommand.Parameters.AddWithValue("@nr_revista", GridView1.DataKeys.ToString()); SqlDataSource1.SelectParameters["@nr_revista"], GridView1.DataKeys.ToString(); sqlCommand.Connection = sqlConn; sqlConn.Open(); sqlCommand.ExecuteNonQuery(); } } } e ele ao clicar no "Delete" devia de apagar: http://gyazo.com/c1ec23d44ff399868aabb6a6a973129f Comprimentos
pikax Posted May 24, 2013 at 09:58 AM Report #508718 Posted May 24, 2013 at 09:58 AM (edited) O melhora o teu query: DELETE FROM Revistas_Detail WHERE (Revistas_Detail.nr_revista = @nr_revista) Edited May 24, 2013 at 09:58 AM by pikax Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender. A beleza de um código está em decompor problemas complexos em pequenos blocos simples. "learn how to do it manually first, then use the wizzy tool to save time." "Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."
Joaanaa.93 Posted May 24, 2013 at 12:37 PM Author Report #508775 Posted May 24, 2013 at 12:37 PM É mesmo isso ! 😄 Obrigada
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now