Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Ingresar(Categoria categoria)
- {
- string sql = "INSERT INTO CATEGORIAS (nombre, descripcion, subcategoria) VALUES (@nombre,@descripcion,@subcategoria)";
- SqlParameter nombreParameter = new SqlParameter("nombre", SqlDbType.NVarChar)
- {
- Value = categoria.Nombre
- };
- SqlParameter descripcionParameter = new SqlParameter("descripcion", SqlDbType.Text)
- {
- Value = categoria.Descripcion
- };
- SqlParameter subcategoriaParameter = new SqlParameter("subcategoria", SqlDbType.Int)
- {
- Value = categoria.Subcategoria
- };
- List<SqlParameter> sqlParameters = new List<SqlParameter>
- {
- nombreParameter,
- descripcionParameter,
- subcategoriaParameter
- };
- try
- {
- connection.ExecuteSQL(sql, sqlParameters);
- }
- catch (Exception e)
- {
- Console.WriteLine("An exception has occurred. " + e.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement