结果中不存在必需的列“TransacionId”。 SQL

时间:2013-12-13 09:03:46

标签: sql sql-server stored-procedures

解决

对于任何有同样问题的人,我加入了已存储的程序,也选择了专栏和交易。

我收到一条错误消息,说我的列TransactionId在结果中不存在?我已经检查了SQL表上的所有名称以及我的类实体,但它仍然说它?

我想将TransactionId传递给我的存储过程,以便返回一些结果。我已经在SQL中测试了存储过程,它工作正常。

这是我的cAuditTransactionsEntity

    [Table(Name = "Audit_Transactions")]
public class cAuditTransactionsEntity
{
    private string _TransactionId;
    private string _PolicyNumber;
    private string _Title;
    private string _Forename;
    private string _Surname;
    private string _PolicyType;
    private int _TransactionUserId;
    private DateTime _TransactionDate;
    private int _TransactionTypeId;
    private string _Insurer;
    private string _ClientPostDetails;
    private int _TransactionStatusId;

    [Column(DbType = "CHAR(32)", IsPrimaryKey = true)]
    public string TransactionId
    {
        get { return _TransactionId; }
        set { _TransactionId = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string PolicyNumber
    {
        get { return _PolicyNumber; }
        set { _PolicyNumber = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string Title
    {
        get { return _Title; }
        set { _Title = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string Forename
    {
        get { return _Forename; }
        set { _Forename = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string Surname
    {
        get { return _Surname; }
        set { _Surname = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string PolicyType
    {
        get { return _PolicyType; }
        set { _PolicyType = value; }
    }

    [Column(DbType = "INT")]
    public int TransactionUserId
    {
        get { return _TransactionUserId; }
        set { _TransactionUserId = value; }
    }

    [Column(DbType = "DATETIME")]
    public DateTime TransactionDate
    {
        get { return _TransactionDate; }
        set { _TransactionDate = value; }
    }

    [Column(DbType = "INT")]
    public int TransactionTypeId
    {
        get { return _TransactionTypeId; }
        set { _TransactionTypeId = value; }
    }

    [Column(DbType = "VARCHAR(50)")]
    public string Insurer
    {
        get { return _Insurer; }
        set { _Insurer = value; }
    }

    [Column(DbType = "VARCHAR(255)")]
    public string ClientPostDetails
    {
        get { return _ClientPostDetails; }
        set { _ClientPostDetails = value; }
    }

    [Column(DbType = "INT")]
    public int TransactionStatusId
    {
        get { return _TransactionStatusId; }
        set { _TransactionStatusId = value; }
    }
}

我看过这个名字并没有区别。

这是我的存储过程:

        [Function(Name = "SP_AUDIT_TRANSACTION_GET_TRANSACTION_INFO", IsComposable = false)]
    public ISingleResult<cAuditTransactionsEntity> GetTransactionInfo(
       [Parameter(Name = "pTransactionId", DbType = "CHAR(32)")] string TransactionId)
    {
        IExecuteResult objResult = this.ExecuteMethodCall(this, (MethodInfo)(MethodInfo.GetCurrentMethod()), TransactionId);

        ISingleResult<cAuditTransactionsEntity> objresults = (ISingleResult<cAuditTransactionsEntity>)objResult.ReturnValue;

        return objresults;
    }

最后,这是我将transactionId传递给存储过程的代码:

    cEvolve_SP sp = new cEvolve_SP(Properties.Settings.Default.AppConnectionString);
    cAuditTransactionsEntity _Transactions;

    public xamlNewAudit(string transactionid)
    {
       _Transactions = new cAuditTransactionsEntity();

        _Transactions.TransactionId = transactionid;

        sp.GetTransactionInfo(transactionid);

        _Transactions.PolicyType = lblPolicyNumber.ToString();

        InitializeComponent();
    }

我收到此错误的行是存储过程中的这一行:

IExecuteResult objResult = this.ExecuteMethodCall(this, (MethodInfo)(MethodInfo.GetCurrentMethod()), TransactionId);

主要是最后一点。

1 个答案:

答案 0 :(得分:0)

OP通过以下方式解决了这个问题

对于任何有同样问题的人,我加入了已存储的程序,也选择了专栏和交易。