运行以下代码时出现此错误:
Ambiguous column name 'AppointmentID'.
Exception Details: System.Data.SqlClient.SqlException: Ambiguous column name 'AppointmentID'.Source Error:
Line 68: adapter.Fill(tbl);
这是导致错误的函数:
public Transaction Payment
{
get
{
return Db.Transaction.FindWhere("[AppointmentID]=@0 AND [Type]='paym'", SqlDb.Params(this.ID));
}
}
交易结构:
public partial class Transaction : SqlRow
{
public int CID { get; set; }
public DateTime Date { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public decimal Amount { get; set; }
public decimal Balance { get; set; }
public int? AppointmentID { get; set; }
public int LocationID { get; set; }
}
可能是什么原因?
请您参考如下方法:
异常说明了一切。在不同的表中有多个名称为 AppointmentID 的列。您可以使用 table aliases或在查询中使用 [TableName].[AppointmentID]。
您应该分享您的 SQL 代码以获得更具体的帮助。
