Question

I have 2 table database;

Firt table's columns;

ClubID(Primary key, auto-increment enabled), ClubName

Second table's columns;

ShowID(Primary key, auto-increment enabled), ShowDate, ClubID

User is selecting Club's name on the form, when user selected a name, dates on the table user have selected must be list on form.

Here is the code;

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"]);
            }

This code throws "The table aliases must be unique. [ Name of duplicate alias = Shows ]" exception on the SqlCeCommand GetDates line.

Was it helpful?

Solution

It looks like you were joining shows on itself. I think you were meaning to do this:

SELECT ShowDate FROM Shows INNER JOIN Clubs ON  Shows.ClubID = Clubs.ClubID WHERE Clubs.ClubName='" + cmb_ClubNamesList.SelectedItem.ToString() + "'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top