Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

Got the below code:

Add-Type -AssemblyName ("Sap.Data.SQLAnywhere.v4.5, Version=, Culture=neutral, PublicKeyToken=f222fc4333e0d400")

[bigint] $myvalue = 123456789123456789

$connectionString = "Host=;Server=testserver;DatabaseName=testdb;UserID=DBA;Password=123"

[Sap.Data.SQLAnywhere.SAConnection] $conn = New-Object Sap.Data.SQLAnywhere.SAConnection($connectionString)

[Sap.Data.SQLAnywhere.SACommand] $command = New-Object Sap.Data.SQLAnywhere.SACommand("UPDATE table SET value = ? WHERE value IS NOT NULL", $conn)

[Sap.Data.SQLAnywhere.SAParameter] $parameter = New-Object Sap.Data.SQLAnywhere.SAParameter
$parameter.SADbType = [Sap.Data.SQLAnywhere.SADbType]::BigInt
$parameter.Value = $myvalue
[void] $command.Parameters.Add($parameter)

try {
    [void] $command.ExecuteNonQuery()
} catch {
    Write-Error $_

And got this exception:

Exception calling "ExecuteNonQuery" with "0" argument(s): "Unable to cast object of type 'System.Numerics.BigInteger' to type 'System.IConvertible'."

I managed to work around this problem by setting $myValue to a string instead of a BigInt.

Are BigInts supported natively with SQLAnywhere .NET Connector?

asked 24 Jan '18, 12:07

tyteen4a03's gravatar image

accept rate: 100%

I do not like writing answers, because I am not the SA developer :) But I have another question for you:

How big is yours BigInteger? MSDN says this number is very large. So large that you cannot even imagine the half of it. Nevertheless, SA supports following numeric types. If you ask yourself, whether 8-bytes integer fits your requirements, so you shouldn't use BigInteger in this case, otherwise I suggest you to use binary types.

That is why BigInteger cannot be converted to any primitive data type such as shortint/int/longint/verylongint/veryverylongint.

(25 Jan '18, 04:17) Vlad
Replies hidden

Whoops - sometimes I forget PowerShell's BigInt is not the same thing as SA's BigInt :)

(25 Jan '18, 05:38) tyteen4a03
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 24 Jan '18, 12:07

question was seen: 1,925 times

last updated: 25 Jan '18, 05:38