Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't execute command when connection has never been opened #584

Closed
dharmenbavaria opened this issue Jan 23, 2023 · 6 comments
Closed

Can't execute command when connection has never been opened #584

dharmenbavaria opened this issue Jan 23, 2023 · 6 comments
Assignees
Labels
bug status-in_progress Issue is worked on by the driver team

Comments

@dharmenbavaria
Copy link

dharmenbavaria commented Jan 23, 2023

Issue description

We are getting this error on production code with the exception message "Can't execute a command when the connection has never been opened", I have no clue why the SFSession state is null.

Situation
We have a different repository for create, update and delete, and for every method execution, we create a connection execute the query and close the connection.

Locally we never have this issue only in production code.

Example code

using (IDbConnection conn = new SnowflakeDbConnection())
{
    conn.ConnectionString = "***";

    conn.Open();
   // running a query
    conn.Close();
}

Error log

            
 Can't execute command when connection has never been opened 
          at Snowflake.Data.Client.SnowflakeDbCommand.SetStatement()
         at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteInternal(Boolean describeOnly)
         at Snowflake.Data.Client.SnowflakeDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
         at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()

There is an example in READMD.md file showing you how to enable logging.

Configuration

Driver version:
2.17.0
Dotnet framework and version: E.g. .net framework 4.5.2 or .net standard 2.0
.net 6.0
Server version:
7.2.0

Client OS:
Linux container mcr.microsoft.com/dotnet/aspnet:6.0

@mbwilding
Copy link

Add this to your connection string.

insecuremode=true

@turbodavidson
Copy link

Has there been any movement on or confirmation of this bug? We are experiencing the same issue, but always after one succesful query...

        using var conn = new SnowflakeDbConnection(connectionString);
        using var cmd = conn.CreateCommand();
        cmd.CommandText = $"<query>";
        conn.Open();
        using var reader = cmd.ExecuteReader();
        if (reader.Read()) {
            return reader.GetValue();
        }
        return null;

@sfc-gh-igarish sfc-gh-igarish added the status-in_progress Issue is worked on by the driver team label May 26, 2023
@sfc-gh-dszmolka
Copy link
Contributor

hello and thank you for raising this issue, also apologies for the long period without response. we'll take a look

@sfc-gh-dszmolka
Copy link
Contributor

this issue seems to be related to some connection pool errors which were there indeed with earlier driver versions like 2.0.17 but in the latest one 2.0.25 this should be fixed. Please upgrade to the latest driver and retest - let us know if you still see the same error. Probably we'll require you to share the debug logs with the reproduction as well.

@sfc-gh-dszmolka sfc-gh-dszmolka closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@luizs81
Copy link

luizs81 commented Nov 27, 2023

This is still happening with the Snowflake.Data nuget package 2.1.3.

@sfc-gh-dszmolka
Copy link
Contributor

since we couldn't reproduce it even with 2.0.25 (after all the connection pool fixes), if the issue still occurs for you guys, can someone who still has this issue with the latest Snowflake driver please open a new issue in this repo with a reproducible code example ? Thank you in advance !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status-in_progress Issue is worked on by the driver team
Projects
None yet
Development

No branches or pull requests

6 participants