Bind variable is not set C# and ASP.NET

I’m passing a value (line_id) from an edit button in my HTML page as a bind variable to Snowflake SQL query.

I wrote Console.WriteLine(line_id) to check if I’m getting a null value, but I’m getting an actual value, but still it’s not entering as bind variable.

Below is my script, need a help on this error. Thanks.

String line_id = Request.Query["line_id"];

try 
{
    string connectionString = "ACCOUNT=;ROLE=;WAREHOUSE=; USER=; PASSWORD=;DB=;SCHEMA=";

    using (SnowflakeDbConnection connection = new SnowflakeDbConnection(connectionString))
    {
        connection.Open();
        String sql = "select * from CX_DB.CX_GSLOBAC_BR.XXBAC_SDPOP_FAILURE_REASONS_DUMMY where LINE_ID = :line_id";

        using (SnowflakeDbCommand command = new SnowflakeDbCommand(connection, sql))
        {
            command.Parameters.Add(new Snowflake.Data.Client.SnowflakeDbParameter(":line_id", Snowflake.Data.Core.SFDataType.TEXT));
            command.Parameters[":line_id"].Value = line_id;

            using (SnowflakeDbDataReader reader = (SnowflakeDbDataReader)command.ExecuteReader())
        }
    }
}

  • 2

    I don’t think you want the colon in the .SnowflakeDbParameter(":line_id" call. I think it should be .SnowflakeDbParameter("line_id")

    – 

Leave a Comment