I'm creating a Content Management System. Users must be able to delete content from a database. This does not delete or give an error message, it just does nothing.

protected void deleteBut_Click(object sender, EventArgs e)
    {
        string A_ID = Request.QueryString["A_ID"];

        string sel = "DELETE FROM acomodation WHERE A_ID=" + A_ID;
        string s = "Provider=Microsoft.Jet.OLEDB.4.0; " +
         "Data Source=" + Server.MapPath("calendar.mdb");

        OleDbConnection con = new OleDbConnection(s);
        con.Open();
        OleDbCommand cmd = new OleDbCommand(sel, con);
        cmd.ExecuteNonQuery();
        con.Close();
        con.Dispose();
    }

Maybe try changing the following:

string sel = "DELETE FROM acomodation WHERE A_ID=" + A_ID;

to this instead:

string sel = "DELETE FROM acomodation WHERE A_ID='" + A_ID + "'";
string sel = "DELETE FROM acomodation WHERE A_ID"= @A_ID;

I think it will work

string sel = "DELETE FROM acomodation WHERE A_ID"= @A_ID;

Are you perhaps mixing this up with the parameter method in which the parameter would be directly referenced within the string and externally declared using cmd.Parameters.Add(@A_ID, paramType); ?

In that event would it not be written as:

string sel = "DELETE FROM acomodation WHERE A_ID='@A_ID'";
cmd.Parameters.Add(@A_ID, paramType);
cmd.Parameters["@A_ID"].Value = A_ID;

Just wanting to clarify was all :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.