Database with sql server and c # win forms

0

Hello friends, I have a database like the one in the figure and I manage it from an application in c # windows forms

The problem I have is with the intermediate tables (testsQuests and questionsOptions). When creating an entry from another table, those changes are not reflected in these tables.

That is, I can create tests, questions, and options, but there are no associations in the intermediate tables.

The insert methods declared in Visual Studio are very similar to each other .. here I leave an example

public void Ingresar(String descripcion)
    {//metodo para registrar pregunta en base
        Pregunta nuevaPregunta = new Pregunta();
        nuevaPregunta.descripcion = descripcion;
        mibase.preguntas.InsertOnSubmit(nuevaPregunta);//guardar en preguntas valores ingresados
        mibase.SubmitChanges();
    }

and that's how I invoke it from a button

new Pregunta().Ingresar(txtTituloPregunta.Text);

Some idea to record the relationships in the intermediate tables

    
asked by Kevtho 25.01.2017 в 16:12
source

1 answer

0

Try to perform a

mibase.SaveChanges();

to see the exception and if the DataContext data remain consistent ...

Also from linq you can use access to the related tables by

tabla1.tabla2.valor4 = miValor.ToString();

As long as you have relations in your model imported.

    
answered by 22.06.2017 в 17:54