Toad World® Forums

ArgumentOutOfRangeException


#1

I’m getting the following error message:

System.ArgumentOutO fRangeException

startIndex cannot be larger than length of string.

Parameter name: startIndex

Stack Trace:

at System.String. InternalSubStrin gWithChecks( Int32 startIndex, Int32
length, Boolean fAlwaysCopy)

at Quest.Toad.CodeInsi ght.BaseDialect. GetInsight( IConnection connection,
IParsable piece, ChunkInsight chunkInsight, Int32 offset, List`1 tokens, Int32&
position, Int32 lastToken, BlockInsight endBlock, String defaultSchema, Boolean
filtering, Hashtable extraContext, ObjectInsight objectInsight)

at Quest.Toad.CodeInsi ght.BaseDialect. GetInsight( IConnection connection,
IParsable piece, ChunkInsight chunkInsight, Int32 offset, List`1 tokens, Int32&
position, Int32 lastToken, BlockInsight endBlock, String defaultSchema, Boolean
filtering, Hashtable extraContext, ObjectInsight objectInsight)

at Quest.Toad.CodeInsi ght.BaseDialect. GetInsight( IConnection connection,
IParsable piece, ChunkInsight chunkInsight, Int32 offset, List`1 tokens, Int32&
position, Int32 lastToken, BlockInsight endBlock, String defaultSchema, Boolean
filtering, Hashtable extraContext, ObjectInsight objectInsight)

at Quest.Toad.CodeInsi ght.BaseDialect. GetInsight( IConnection connection,
IParsable piece, ChunkInsight chunkInsight, Int32 offset, List`1 tokens, Int32&
position, Int32 lastToken, BlockInsight endBlock, String defaultSchema, Boolean
filtering, Hashtable extraContext, ObjectInsight objectInsight)

at Quest.Toad.CodeInsi ght.BaseDialect. GetInsight( IConnection connection,
Chunk chunk, Int32 offset, String defaultSchema, Int32& startOffset, Boolean&
hasSecondary, Boolean filtering, Boolean secondary, HotTokenInsight hotToken)

at Quest.Toad.Editor. Commands. InvokeMemberList Command.FetchMem
berListItems( Object editorText)

When I have the following in the SQL editor

INSERT INTO

SELECT

CASE WHEN T.Batch_No = 0 THEN '0' ELSE ISNULL(T.Batch_ No_Type,

‘’) + CAST(T.Batch_ No AS VarChar) END AS IBatchNo,

-1 * P.Payment_Amount As PaymentAmount,

T.Date_Printed AS PaymentDate,

CASE WHEN T.Payment_Method ='Unallocated Cash'

  THEN

    ISNULL(

      (SELECT 

        'Advance Payment'

      FROM acsuTrans_PaymentsU C_Link PUC

      INNER JOIN acsuTrans_Unallocat edCash UC ON UC.Entry_ID =

PUC.UCashEntryID

      INNER JOIN acsuTrans_ReservedC ash RC ON RC.UnCashID =

UC.Entry_ID

      WHERE PUC.PaymentEntryID = P.Entry_ID)

    ,'Unallocated Cash')

  ELSE T.Payment_Method 

END AS PaymentMethod,

CASE 

  WHEN ISNULL(PM.[Type] ,0) = 2 THEN CL.Cheque_No 

  WHEN ISNULL(PM.[Type] ,0) = 1 THEN CL.Cheque_No

  WHEN T.Payment_Method = 'Credit Memo' THEN CAST(P.OtherCounter

AS VARCHAR) – The other counter stores the credit memo used for this payment

  ELSE '' END AS CheckNo,

T.Transaction_ ID AS PaymentTransID,

T.TransUserName AS IUserName,

P.Account_No AS PayAccountNo,

P.Invoice_Paid AS InvoiceTransID,

P.Invoice_Paid AS InvoicePaid,

CASE WHEN ISNULL(P.Reversed, 0) = 1 THEN 1 ELSE CASE WHEN

ISNULL(P.Bounced, 0) = 1 THEN 1 ELSE 0 END END AS Reversed,

T.Remark AS IRemark

FROM acsuTrans_Payments P

INNER JOIN acsuTransactions T ON T.Transaction_ ID = P.Batch_Counter

LEFT JOIN ARSYpaymentmethods PM ON PM.pay_methods = T.Payment_Method

INNER JOIN acsuTrans_CashListi ng CL ON CL.Transaction_ ID = T.Transaction_
ID

INNER JOIN acsuTransactions I ON I.Transaction_ ID = P.Invoice_Paid

WHERE I.Account_No = @AccountNo

AND I.Transaction_ Type IN ('Invoice', 'Ad-Hoc Invoice')

AND I.Date_Printed BETWEEN @StartDate AND @EndDate

I was trying to go back to the beginning of the SQL and put in a INSERT INTO
#TempTable but as soon as I type the INSERT INTO I get the error message I
pasted above.


Charles Haines
Senior Software Developer
P: (410) 535-5590 x1196

Recorded Books, LLC
http://www.recorded books.com