Parametrized query with Snowflake and pass the values from Snowflake .NET Connector

Viewed 1295

Create parameterize with Snowflake as like MySQL and SQL Server. Need to pass the values from .NET Snowflake .NET Connector.

https://www.mssqltips.com/sqlservertip/2981/using-parameters-for-sql-server-queries-and-stored-procedures/

Query with value:

select * 
from "SNOWFLAKE_SAMPLE_DATA"."TPCDS_SF100TCL"."WEB_SITE" 
where ((Web_REC_START_DATE is null and IFF('2000-08-16' is null,true,false))    
       or Web_REC_START_DATE > '2000-08-16')

How to use SqlDataReader with a parametrized query in c#?

Query with names of parameters:

select * 
from "SNOWFLAKE_SAMPLE_DATA"."TPCDS_SF100TCL"."WEB_SITE" 
where ((Web_REC_START_DATE is null and IFF(@StartDate is null,true,false)) 
       or Web_REC_START_DATE > @StartDate)
1 Answers

the snowflake .net connector, is hosted in github, and it's read me describes how to in the bind-parameter section

so looking at the tests in the code, specifically the BindTest line 75

it shows named parameters being used. thus:

command.CommandText = "insert into TEST_TBL values(:p0)";
var param = command.CreateParameter();
param.ParameterName = "p0";
param.DbType = System.Data.DbType.Int32;
param.Value = DBNull.Value;
command.Parameters.Add(param);
Related