public void CrearCommentBasic(string text, int codActividad, string codUser, DateTime date)
{
string comando;
if (codUser == null) {
comando = "INSERT INTO [Comentario](texto,actividad,fecha) VALUES('" + text + "', '" + codActividad + "', '" + date+ "')";
} else {
comando = "INSERT INTO [Comentario](texto,actividad,usuario,fecha) VALUES('" + text + "', '" + codActividad + "', '" + codUser + "', '" + date+ "')";
}
SqlConnection c = null;
SqlCommand comandoTBD;
try
{
c = new SqlConnection(conexionTBD);
comandoTBD = new SqlCommand(comando, c);
c.Open();
comandoTBD.CommandType = CommandType.Text;
comandoTBD.ExecuteNonQuery();
}
catch (SqlException)
{
throw;
}
finally
{
if (c != null) c.Close(); // Se asegura de cerrar la conexión.
}
}