A transport-level error has occurred when receiving results from the server

  • Thread starter Thread starter loftty
  • Start date Start date
L

loftty

Guest
Hi, I am having an issue with my code where i get the following error

"A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)"

when i call the below code thousands of times

public Dictionary<string, string> GetParameters(Guid instanceid)
{
DataSet ds = new DataSet();
Dictionary<string, string> parameters = new Dictionary<string, string>();
using (SqlCommand cmd = new SqlCommand("GetRParameters", instancesql.SqlConnection))
{
SqlDataAdapter adapter;
cmd.CommandType = CommandType.StoredProcedure;
if (instancesql.SqlConnection.State == ConnectionState.Closed)
instancesql.SqlConnection.Open();

cmd.Parameters.Add("@InstanceId", SqlDbType.UniqueIdentifier).Value = instanceid;

adapter = new SqlDataAdapter(cmd);
adapter.Fill(ds);

if (ds.Tables.Count > 0)
{
foreach (DataRow item in ds.Tables[0].Rows)
{
var pars = (String)item["Parameters"];
if (!string.IsNullOrEmpty(pars))
parameters = JsonConvert.DeserializeObject<Dictionary<string, string>>(pars);
}
}

ds.Dispose();
cmd.Dispose();
adapter.Dispose();
}

ds.Dispose();
return parameters;
}


My connection string is something like so "Data Source=localhost;Integrated Security=True;MultipleActiveResultSets=True;Connect Timeout=0"

Any ideas?

Regards,

Loftty

Continue reading...
 
Back
Top