Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

can connect to database with Npgsql 2.2.7 and npgsql.entityframwoek but cant connect when i upgrade to npgsql 5.0.3 and entity.framwork6,

$
0
0

im getting "connection is not open" error when i tried to upgrade the nuget package of Npgsql from 2.2.7 to 5.0.3, i even updated the Npgsql.entityFramework 2.2.7 tp Npgsql.entityframework6 6.4.1. Could anyone there tell what are things i need to check and what im missing out when i upgrade the nuget package, i been googling but couldnt find any solution. appreciate someone out ther can help with this issue im facing,

connection string :

Server=103.215.136.90;Database=myDataBase;Port=5432;Userid=postgres;Password=paysys1;Pooling=true;Protocol=3;Timeout=60;CommandTimeout=60;MinPoolSize=2;MaxPoolSize=60;

config:

<dependentAssembly><assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" /></dependentAssembly><dependentAssembly><assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" /><bindingRedirect oldVersion="0.0.0.0-5.0.3.0" newVersion="5.0.3.0" /></dependentAssembly></assemblyBinding></runtime><entityFramework><providers><provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /><provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" /></providers><defaultConnectionFactory type="Npgsql.NpgsqlConnectionFactory, EntityFramework6.Npgsql" /></entityFramework>

Code:

public bool GetRawFile(string Family, string Acquirer, string TID, ref string Raw_Data)        {            bool lb_rtn = false;            try            {                using (NpgsqlConnection cn = new NpgsqlConnection(conn))                {                    NpgsqlCommand cmd = new NpgsqlCommand();                    cmd.Connection = cn;                    cmd.CommandText = "select data.\"sp_Generate_Raw_Data_For_Download\"(@P1,@P2,@P3);";                    cmd.Parameters.AddWithValue("@P1", Family);                    cmd.Parameters.AddWithValue("@P2", Acquirer);                    cmd.Parameters.AddWithValue("@P3", TID);                    //this will help to switch between databases                    if (cn.Database == SettingsParam.DataDB_Name)                        cn.Open();                    else                        cn.ChangeDatabase(SettingsParam.DataDB_Name); //this will change current database                     var rtn_data = cmd.ExecuteScalar();                    cn.Close();                    Raw_Data = rtn_data.ToString();                    if (Raw_Data != null)                    {                        if (Raw_Data != "")                        {                            lb_rtn = true;                        }                    }                }            }            catch (Exception ex)            {                redirect.ErrorLog(ex.Message);            }            return lb_rtn;        }

Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>