在c#中选择具有相同值的表中的多个单元格

时间:2016-06-09 11:09:15

标签: c# sql sql-server visual-studio

我试过这段代码:

SqlCommand selectcurrentuserid = new SqlCommand("select ID_UTENTI from UTENTI where USERNAME_UTENTI='" + Login.currentUser + "'", conn);
currentuserid = (int)selectcurrentuserid.ExecuteScalar();
SqlCommand selectarea = new SqlCommand("select ID_AREA from VISUALIZZAZIONE_UTENTI where ID_UTENTE='" + currentuserid + "'", conn);
msa = new SqlDataAdapter("select * from AREAGEOMETRY1 where AREAGEOMETRY_PROTEZIONE='false' or AREAGEOMETRY_WINAAREA_ID='" + (int)selectarea.ExecuteScalar() + "'", conn);
msa.Fill(data);

但是这样命令selectarea只选择第一个ID_AREA而不是所有具有相同值的ID_ARA。

0 个答案:

没有答案