Error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement

0

I'm doing a project that consists of using a MySQL database with a graphical interface of C #, the point is that there is an item / element that consists of adding 2 dates but when compiling I get an error with the "DateTimePicker" ".

My code is as follows:

void BtnAgregarClick(object sender, EventArgs e){
    String A,B,C,D,E;
    A = txtCodigo.Text;
    B = txtISBN.Text;
    C = txtBoleta.Text;
    D = dateTimePicker1.Text;
    E = dateTimePicker2.Text;
    if (A != "" && B != "" && C !=null && D != null && E != null){
        string query = "INSERT INTO prestamo VALUES("+"'" + A + "'," + "'" + B + "'," + "'" + C +"'," +  "'" + D + "'," + "'" + E + "')";
        MessageBox.Show(query);
        MainForm.Insert(query);
        txtBoleta.Clear();
        txtCodigo.Clear();
        dateTimePicker1.Value == DateTime.Today;
        dateTimePicker2.Value == DateTime.Today;
    }
    else 
        MessageBox.Show("Ingresa todos los datos");

}
    
asked by AldoMunoZz 10.06.2018 в 06:51
source

1 answer

1

Hello your problem is that you are making a comparison instead of an assignment in this part of your code

dateTimePicker1.Value == DateTime.Today;  
dateTimePicker2.Value == DateTime.Today;

Use the assignment operator = instead of the comparator ==

    
answered by 10.06.2018 / 11:25
source