我正在尝试显示与输入到文本框中的姓氏匹配的所有记录。这需要在“volID”列上进行 INNER JOIN,因为有 2 个表。
<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)