您好我有三個表這樣嵌套在三個表選擇
////////////////////////////////////////////
PlaceCodename | DeviceConfig | DevInOut
---------- | ------------ | --------
Place_name | IP (PK) | IP
Place_code (PK) | Place_code | Action
| TypeofUseCode | Cardserial (PK)
| deevNum | date (PK)
| time (PK)
對於每個Cardserial有一些IP地址可以被重複。這意味着DevInOut的主鍵是(日期,時間和Cardserial)的組合。
我想給Cardserial並根據IP從DeviceConfig獲取Place_code,並基於PlaceCodename表獲取Place_name。
我寫這個查詢,但它不工作:
SqlDataAdapter a = new SqlDataAdapter("select Place_code from DeviceConfig inner join (select IP from DevInOut where Cardserial = '" + textBox12.Text + "') tb on
DeviceConfig.IP = tb.IP)", con);
SqlCommandBuilder comdBuilder = new SqlCommandBuilder(a);
DataTable t = new DataTable();
t.Locale = System.Globalization.CultureInfo.InvariantCulture;
a.Fill(t);
bindingSource1.DataSource = t;
........
我沒有工作甚至嘗試數據表either.How我可以解決我的問題?
「但是它不工作:」 - 請解釋如何這是行不通的! –