2016-08-10 68 views
0

私のコードは、次のエラーを示します。どうすれば修正できますか?アイテムは、要求された名前または序数に対応するコレクションに見つかりません

項目は、それはあなたの列名のいずれかを認識していないと言っています要求された名前または序

ElseIf Me.chkItem.Checked = True Then 
    Dim CheckNumber As String = "" 
    Dim CheckRef As String = "" 
    dsvoucheritem.Clear() 
    DSVoucher_Expense.Clear() 
    DSVoucher_Check.Clear() 

    Try 
     Me.lstCV.Items.Clear() 
     strDiscount = Nothing 
     rec.Open("select billpaymentcheckline.txnnumber, billpaymentcheckline.txndate" _ 
     & ", billpaymentcheckline.payeeentityreffullname" _ 
     & ", billpaymentcheckline.amount, billitemline.itemlineitemreffullname" _ 
     & ", billitemline.memo" _ 
     & ", billpaymentcheckline.appliedtotxndiscountamount" _ 
     & ", billpaymentcheckline.appliedtotxnrefnumber, billpaymentcheckline.bankaccountreffullname" _ 
     & ", billpaymentcheckline.appliedtotxndiscountaccountreffullname" _ 
     & ", billpaymentcheckline.appliedtotxntxndate, billpaymentcheckline.appliedtotxnamount" _ 
     & ", billpaymentcheckline.refnumber, account.AccountNumber from (billitemline inner join" _ 
     & " billpaymentcheckline on billitemline.refnumber=billpaymentcheckline.appliedtotxnrefnumber) left outer join" _ 
     & " account on billitemline.APAccountreflistid=account.listid where" _ 
     & " billpaymentcheckline.bankaccountreflistid='" &Me.lblBankID.Text & "' and" _ 
     & " billpaymentcheckline.refnumber between '" & CInt(Me.txtRefFR.Text) 
     & "' and '" & CInt(Me.txtRefTO.Text) & "'", con, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly) 
+1

このコードは、SQLインジェクションのセキュリティ上の脆弱性のために広く公開されています。パラメータ化されたクエリを使用する方が安全です。 –

答えて

0

に対応するコレクションで見つけることができません。それらをすべてダブルチェックしてください。また、犯人を見つけるまでフィールドを削除することもできます。

+0

外部結合を削除して、この "[QODBC]字句要素が見つかりません"のようなエラーが表示される – Maine

+0

探している要素がaccountです。何かがアカウントを参照していますか? – FloatingKiwi

+0

あなたの結合はおそらくうまくいきます。列名を確認してください。 – FloatingKiwi

0

memoは、Access SQLのreserved wordです。

Try billitemline.[memo]

+0

@メイン:これを試してみましたか? – Andre

関連する問題