From 64b0b6bf1d82da1d47938556aab6e6ca274078c0 Mon Sep 17 00:00:00 2001 From: sfc-gh-dszmolka Date: Wed, 29 Nov 2023 17:59:24 +0100 Subject: [PATCH] SNOW-978294 provide usage example on how to insert data into a VARIANT column example kindly provided by @rkdnc9 --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 13f2ca41d..1f75967ad 100644 --- a/README.md +++ b/README.md @@ -643,6 +643,21 @@ using (IDbConnection conn = new SnowflakeDbConnection()) } ``` +Writing to `VARIANT` column with bind variable +---------------------------------------------- +You can use bind variables together with `VARIANT` datatype column. For example, to insert data: +```cs +cmd.CommandText = "insert into table (id, data) select :id, parse_json(:data)" +``` +then reference the `SFDataType` for the named parameter, `p2` in this example: +```cs +p2.SFDataType = SFDataType.TEXT +``` +As an alternative, you can use an approach like: +```cs +var p2 = new SnowflakeDbParameter("data", SFDataType.TEXT) { Value = jsonStr }; +``` + Close the Connection --------------------