linq to SQL does not update data since you install visual studio 2017

0

Since installing visual studio 2017 I do not update the data in the database with linq. check the code many times and it's all good, it's more from other projects I also stop updating. I think it's a problem of the LinQ class but the point is that I can not update anything. With try and catch, I'm not mistaken. I do not know what to do, I'm half desperate. Use Visual Studio 2017 with SQL SQLSERVER 2017

It's an example that I created to show the problem. But I already tried other projects that worked perfectly but now they do not work for me

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
    DataClasses1DataContext db = new DataClasses1DataContext();

    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

        try
        {
            afiliados af = db.afiliados.Where(x => x.DNI == 
            "26954776").Single();
            af.ASAMBLEA = 1;
            af.VOTO = 1;
            af.TELEFONO_SOCIO = 111;
            db.SubmitChanges();
        }
        catch (Exception )
        {
            MessageBox.Show("problema");
            throw;
        }
    }
}
}

Then I execute the query in the SQLServer 2016 and it does not modify.

select  * from afiliados where dni = '26954776'

shows the unmodified data as result

that is, the fields ASSEMBLY, VOTE, TELEPHONE_SOCIO are not modified. Now install and uninstall the visual studio and the SQLServer and nothing remains the same. Will it be that with VS2017 I change the way I work with linqtosql? If you can help me, please. THANK YOU !!!!!

    
asked by Diego Perez 01.09.2017 в 05:54
source

1 answer

0

Due to lack of time I could not respond quickly. I answer with the solution you find in case it is still useful.

For what I understand of your code. You are looking to update a record using EF. Try to simulate your situation and this is the solution I found:

It would be a matter of adapting the code

    
answered by 05.09.2017 в 01:37