The document describes how to connect to SQL databases and perform CRUD (create, read, update, delete) operations using ADO.NET. It includes examples of connecting to SQL Server Compact, SQL Server Express, and remote databases. It also shows how to execute SQL statements and stored procedures to insert, update, delete records as well as retrieve data and return datasets. Stored procedures are created to encapsulate the CRUD logic and are called by passing parameter values.
The document describes how to connect to SQL databases and perform CRUD (create, read, update, delete) operations using ADO.NET. It includes examples of connecting to SQL Server Compact, SQL Server Express, and remote databases. It also shows how to execute SQL statements and stored procedures to insert, update, delete records as well as retrieve data and return datasets. Stored procedures are created to encapsulate the CRUD logic and are called by passing parameter values.
The document describes how to connect to SQL databases and perform CRUD (create, read, update, delete) operations using ADO.NET. It includes examples of connecting to SQL Server Compact, SQL Server Express, and remote databases. It also shows how to execute SQL statements and stored procedures to insert, update, delete records as well as retrieve data and return datasets. Stored procedures are created to encapsulate the CRUD logic and are called by passing parameter values.
The document describes how to connect to SQL databases and perform CRUD (create, read, update, delete) operations using ADO.NET. It includes examples of connecting to SQL Server Compact, SQL Server Express, and remote databases. It also shows how to execute SQL statements and stored procedures to insert, update, delete records as well as retrieve data and return datasets. Stored procedures are created to encapsulate the CRUD logic and are called by passing parameter values.
Insertar CREATE PROCEDURE sp_InsertUsuarios @Nombre nvarchar(50), @Apellido nvarchar(max), @AreadeTrabajo nvarchar(max), AS BEGIN INSERT INTO tbUsuarios (Nombre,Apellido,AreadeTrabajo)VALUES(@Nombre,@Apellido,@AreadeTrabajo) END GO
Update CREATE PROCEDURE sp_UpdateUsuario @Nombre nvarchar(50), @Apellido nvarchar(max), @AreadeTrabajo nvarchar(max), AS BEGIN UPDATE tbUsuarios SET Nombre=@Nombre,Apellido=@Apellido,AreadeTrabajo=@AreadeTrabajo WHERE Usuario=@Usuario END GO
Delete CREATE PROCEDURE sp_BorrarUsuario @usuario nvarchar(50) AS BEGIN DELETE FROM tbUsuarios WHERE Usuario=@usuario END GO con=new SqlConnection(CadenaConexion); cmd = new SqlCommand("sp_InsertUsuarios", con); cmd.CommandType = CommandType.StoredProcedure;
con.Open(); cmd.ExecuteNonQuery(); con.Close(); con = new SqlConnection(CadenaConexion); cmd = new SqlCommand("sp_SelectUsuario", con); cmd.CommandType = CommandType.StoredProcedure;