2

I'm using Access and SqlServer. I had a table field "inv_base64_code" and type nvarchar(max)

 cmd.Parameters.Append cmd.CreateParameter("@p_inv_base64_code", adVarChar, adParamInput, 500, Nz(!inv_base64_code, ""))

How could I refer to max length in vba cmd.Parameter because 500 not enough even 8000 not enough sometimes?

June7
  • 19,874
  • 8
  • 24
  • 34
A.J
  • 45
  • 5
  • 1
    If I remember correctly, using `-1` for the max length *should* work, but I don't have an official source to back this up (hence only a comment). – Heinzi Aug 06 '23 at 16:45
  • Why would 8000 not be enough? Source says max for Nvarchar is 4000 https://www.tutorialscan.com/sql/difference-between-varchar-and-nvarchar/#:~:text=A%20Varchar%20can%20stores%20maximum%208000 – June7 Aug 06 '23 at 18:24
  • @June7: That limit is only for `[n]varchar(someNumber)`. `[n]varchar(max)` (= the successor of `[n]text`) is something completely different and can store up to 2GB. – Heinzi Aug 07 '23 at 09:19
  • as per Saudi Arabia "ZATCA" regulation this code field will handle all invoice data encrypted in base 64 , and other field will contain all XML invoice text encoded in 64 , some invoices header and detail exceed 10000 char – A.J Aug 07 '23 at 20:43
  • 1
    @AhmedAboelez: So, did -1 work? – Heinzi Aug 07 '23 at 20:59
  • @Heinzi yes work with no error Thank You Sir – A.J Aug 07 '23 at 21:06

0 Answers0