public void insertTask(Tarea user) { cmd = new SqlCommand(); cmd.Connection = cnn; cmd.CommandText = "INSERT INTO Tarea (nombre,descripcion,usuario_id) VALUES ('" + user.nombre + "','" + user.description + "','" + user.usuario_id + "');"; adapter = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); }
public void insertUser(Usuario user) { cmd = new SqlCommand(); cmd.Connection = cnn; cmd.CommandText = "INSERT INTO usuario (nombre,direccion,telefono) VALUES ('" + user.nombre + "','" + user.direccion + "','" + user.telefono + "');"; adapter = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); cmd.CommandText = "select TOP 1 usuario_id from usuario order by usuario_id desc"; adapter = new SqlDataAdapter(cmd); cmd.ExecuteNonQuery(); adapter.Fill(ds); Tarea tarea = new Tarea() { nombre = "TaskBase", description = "", usuario_id = ds.Tables[0].Rows[0][0].ToString() }; insertTask(tarea); }
public void insert(Tarea user) { try { db = new AccessData(); db.openConection(); db.insertTask(user); } catch (Exception a) { } finally { db.closeConection(); } }