我試圖顯示與輸入到文本框中的姓氏相匹配的所有記錄。 這需要在「volID」列上有一個INNER JOIN,因爲有兩個表。Inner Subsonic與subsonic
<asp:TextBox ID="lName" runat="server"></asp:TextBox>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true" Visible="true"></asp:GridView>
<asp:linkButton ID="btnSubmit" runat="server" onclick="btnSubmit_Click" />
後面的代碼:
protected void btnSubmit_Click(object sender, EventArgs e)
{
GridView1.DataSource = new Select("*")
.From(PastAwardName.Schema)
.InnerJoin(PastAwardName.VolIDColumn, PastAwardType.VolIDColumn)
.Where(PastAwardName.Columns.LName).IsEqualTo(this.lName.Text)
.ExecuteReader();
GridView1.DataBind();
}
我試圖從與例如在Subsonics網站做到這一點,但不能得到它的工作。通過下面的錯誤發佈。
Server Error in '/' Application.
________________________________________
The objects "dbo.pastAwardNames" and "dbo.pastAwardNames" in the FROM clause have the same exposed names. Use correlation names to distinguish them.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The objects "dbo.pastAwardNames" and "dbo.pastAwardNames" in the FROM clause have the same exposed names. Use correlation names to distinguish them.
Source Error:
Line 30:
Line 31:
Line 32: GridView1.DataSource = new Select("*")
Line 33: .From(PastAwardName.Schema)
Line 34: .InnerJoin(PastAwardName.VolIDColumn, PastAwardType.VolIDColumn)
哪裏/怎麼會是第二個表中定義?它從錯誤中看出它試圖將自己的表連接到同一個表。 – geofftnz 2009-04-14 21:39:17
PastAwardName是第一個表 - PastAwardType是第二個表。我正在嘗試加入volID專欄。 – Brett 2009-04-15 15:00:38