UNIDAD 5: INTRODUCION BASES DE DATOS VISUAL C# 2005

TEMA 12: BAJA O ELIMINACION SQL DELETE

Eliminacion es otro proceso simple y comun con las bases de datos el modelo con ADO NET que estamos usando hace este tipo de operaciones muy faciles:

La instruccion sql a usar es:

DELETE FROM TABLA WHERE CONDICION

Y DELETE USA OBJETO COMMAND

Programa


private void button1_Click(object sender, EventArgs e)

{

// Objetos OLEDB que se ocupan

OleDbConnection CANAL;

OleDbCommand ORDEN;

CANAL = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\datos\\mibase.mdb");

// Instruccion sql DELETE FROM TABLA WHERE CLAVE=DATO

string q = "delete from mitabla where clave=@CLAVE";

ORDEN = new OleDbCommand(q, CANAL);

ORDEN.Parameters.Add(new OleDbParameter("@CLAVE", OleDbType.Integer));

ORDEN.Parameters["@CLAVE"].Value = CLAVE.Text;

ORDEN.Connection.Open();

ORDEN.ExecuteNonQuery();

ORDEN.Connection.Close();

// Avisando

label2.Text = " REGISTRO ELIMINADO";

}

No hay notas nuevas.

Corrida

image373.jpg

TAREAS PROGRAMACION VISUAL C# 2005:

1.- Construir este proceso para las tablas y bases de datos que tengan del programa de menu.

 




Google
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
Politica de Privacidad