0

我有 2 个表数据库;

Fit 表的列;

ClubID(主键,启用自动增量),ClubName

第二个表的列;

ShowID(Primary key, auto-increment enabled), 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 行上引发“表别名必须是唯一的。[重复别名的名称 = Shows]”异常。

4

1 回答 1

1

看起来你是自己加入节目的。我认为你的意思是这样做:

SELECT ShowDate FROM Shows INNER JOIN Clubs ON  Shows.ClubID = Clubs.ClubID WHERE Clubs.ClubName='" + cmb_ClubNamesList.SelectedItem.ToString() + "'"
于 2011-02-21T15:20:29.413 回答