So i have problem. I have a SQL server with DB and 2 tables:
1-|id|name|,
2-|id|id_id|name|;
id->id_id has a conection.
I connected SQL to VS like a DataSource.
I have 3 forms in VS(C#): MainForm(for select forms with DataGridView’s), form with DGV1 and form with DGV2.
So first open MainForm, next by button form with DGV1. I can add, delete and change rows, but i need do button for select row(need select id or get his value), next close form DGV1.
Next open form DGV2 by button on MainForm and at the time of opennig need do query for DGV2 like a:
SELECT id, id_id, name FROM TABLE WHERE (id_id = selected id from DGV1)
How to do this?
If I understand you want to select info from the second table for a given id_id.
If so, you have to save the id from DG1 somewhere and then select the data like this:
where @idDG1 must be the value itself. If you select id 1 from DG1 the query must be:
and so on.
One final note, you can use @idDG1 and add a parameter when building the query.