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

Doesn't auto-dispose connection & exception occurs when connection opened inside command #64

Closed
rshenton opened this issue Sep 17, 2018 · 1 comment
Assignees
Milestone

Comments

@rshenton
Copy link

Issue description

-using statement on connection should auto-dispose connection, but doesn't -> (should override Dispose & call Close)
-should allow connection to be opened in command?

Example code

//THIS WORKS AND CLOSES CONNECTION
var con = new Snowflake.Data.Client.SnowflakeDbConnection();
con.ConnectionString = "CONNECTION_STRING_HERE";
try
{   
    con.Open();

    using (var cmd = new Snowflake.Data.Client.SnowflakeDbCommand(con))
    {
        //cmd.CommandType = CommandType.Text;
        cmd.CommandText = query;

        using (var da = new Snowflake.Data.Client.SnowflakeDbDataAdapter(cmd))
        {
            da.Fill(dt);
        }
    }
}
finally
{
    con.Close();
}

//THIS DOESN'T WORK AND FAILS TO CLOSE CONNECTION
using (var con = new Snowflake.Data.Client.SnowflakeDbConnection())
{
    con.ConnectionString = "CONNECTION_STRING_HERE";
                
    using (var cmd = new Snowflake.Data.Client.SnowflakeDbCommand(con))
    {
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = query;

        con.Open();
        using (var da = new Snowflake.Data.Client.SnowflakeDbDataAdapter(cmd))
        {
            da.Fill(dt);
        }
    }

    //con.Close(); //This line doesn't matter since exception happens above and gets bypassed
}

Configuration

Snowflake.Data(1.0.4)
netcoreapp2.0

@howryu
Copy link
Contributor

howryu commented Sep 18, 2018

Thanks for your report. auto-dipose is a known issue, we have some other resources are not auto-dispose, #20.

For the second one, I will check why it is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants