我有2个表数据库;
Firt table的列;
ClubID(主键,启用自动增量),ClubName
第二个表的列;
ShowID(主键,启用自动增量),ShowDate,ClubID
用户在表单上选择俱乐部名称,当用户选择名称时,用户选择的表格上的日期必须在表格上列出。
这是代码;
SqlCeConnection Conn = new SqlCeConnection("Data Source=|DataDirectory|CeoDatabase.sdf;Password=CeoDB;Persist Security Info=True");
Conn.Open();
SqlCeCommand GetDates = new SqlCeCommand("SELECT ShowDate FROM Shows INNER JOIN Shows ON Shows.ClubID = Clubs.ClubID WHERE Clubs.ClubName='" + cmb_ClubNamesList.SelectedItem.ToString() + "'", Conn);
SqlCeDataReader WriteDates= RezervasyonlariAl.ExecuteReader();
while (WriteDates.Read())
{
cmb_ClubNamesList.Items.Add(WriteDates["ShowDate"]);
}
此代码抛出“表别名必须唯一。[重复别名的名称=显示]”SqlCeCommand GetDates行上的异常。
答案 0 :(得分:0)
看起来你正在加入节目。我认为你这样做的意思是:
SELECT ShowDate FROM Shows INNER JOIN Clubs ON Shows.ClubID = Clubs.ClubID WHERE Clubs.ClubName='" + cmb_ClubNamesList.SelectedItem.ToString() + "'"