I am trying to store a BigInteger as a DECIMAL(36,18) in C#. When I try to add the value like this:
public void AddTrade(BigInteger price) {
_connection.Open();
var command = new MySqlCommand(@"INSERT INTO Prices (Price) VALUES (@Price);", _connection);
command.Parameters.Add("@Price", MySqlDbType.Decimal).Value = price;
command.ExecuteNonQuery();
_connection.Close();
}
I get the following exception:
System.NotSupportedException: 'Parameter type BigInteger is not supported;
Here is how I created the table:
public void CreatePriceTable() {
_connection.Open();
var createTable = new MySqlCommand(
@"
CREATE TABLE `Prices` (
Price DECIMAL(36,18) NOT NULL,
) COLLATE='utf8_general_ci' ENGINE=InnoDB;"
, _connection);
createTable.ExecuteNonQuery();
_connection.Close();
}
I wasn't able to find the solution in any documentation and hope someone can help me with this. Thank you!
edit: The reason I need to use a BigInteger is because I am receiving a price in Wei (the smallest unit on the Ethereum blockchain) as BigInteger. One Ether is 1000000000000000000 Wei. Other posts suggested using DECIMAL(36,18) for Wei.