none
como usar DELETE WHERE access

    Question

  • hola! quería saber como utilizar la sentencia DELETE en donde borro un registro que escribo en un textbox de la base de datos en access
    Thursday, May 31, 2012 11:22 PM

Answers

  • hola

    podria ser

    string connstring = "connection string";
    using (OleDbConnection cn = new OleDbConnection(connstring)) {
        cn.Open();
    
        string query = "DELETE FROM Table WHERE id = @id";
        OleDbCommand cmd = new OleDbCommand(query, cn);
        cmd.Parameters.AddwithValue("@id", Textbox1.Text);
    
        cmd.ExecuteNonQuery();
    
    }

    salduos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina


    Thursday, May 31, 2012 11:39 PM
  •  

    Hola

    > string sql = "DELETE FROM table1 WHERE id = @id";
    OleDbCommand cmd = new OleDbCommand(sql, cn);


    Friday, June 01, 2012 12:47 AM

All replies

  • hola

    podria ser

    string connstring = "connection string";
    using (OleDbConnection cn = new OleDbConnection(connstring)) {
        cn.Open();
    
        string query = "DELETE FROM Table WHERE id = @id";
        OleDbCommand cmd = new OleDbCommand(query, cn);
        cmd.Parameters.AddwithValue("@id", Textbox1.Text);
    
        cmd.ExecuteNonQuery();
    
    }

    salduos


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina


    Thursday, May 31, 2012 11:39 PM
  • HOLA! Tengo el siguiente codigo:

    private void bteliminar_Click(object sender, EventArgs e)
            {
                string connstring = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=diccionario1.mdb";
                using (OleDbConnection cn = new OleDbConnection(connstring))
                {
                    cn.Open();

                    string sql = "DELETE FROM table1 WHERE id = @id";
                    OleDbCommand cmd = new OleDbCommand(query, cn);
                    cmd.Parameters.AddwithValue("@id", Textbox1.Text);

                    cmd.ExecuteNonQuery();

                }
            }

    pero no me reconoce el query ni el addwithValue

    Friday, June 01, 2012 12:41 AM
  •  

    Hola

    > string sql = "DELETE FROM table1 WHERE id = @id";
    OleDbCommand cmd = new OleDbCommand(sql, cn);


    Friday, June 01, 2012 12:47 AM
  • ups , si quivoque los nombres de las variables, ya esta editado

    pero me pregunto, como compilo ese codigo porque la variable query no esta declarada


    Leandro Tuttini

    Blog
    Buenos Aires
    Argentina

    Friday, June 01, 2012 12:55 AM