I have 2 datagridviews in my winform project. one of them is a list with the names of my "combos", and the other one is supposed to show me all the information of the selected name with the following query which is the datasource to the datagrid2
SELECT Combo.id_combo, Combo.name, Combo.price, Producto.name AS Expr1, Producto.price AS Expr2
FROM Combo INNER JOIN
Detalle ON Combo.id_combo = Detalle.id_combo INNER JOIN
Producto ON Detalle.id_producto = Producto.id_producto
WHERE (Combo.name = @name)
but when I execute the code the following error pops up: Failed to enable constraints. One or more rows contain values violating the NON-NULL, UNIQUE, or FOREIGN-KEY constraints.
I know the query works since I've tested it on my SQL server but it seems I can't set it as the datasource for my table.
I'm setting the table datasource like this, once the click event on the first datagrid is detected and the name is captured
datagridview2.datasource=combo.detail(name);
combo.detail is a function of the class I use to connect to my database which will execute the query with the name as the parameter to send.
Why is it not working?